如題!Delphi調用一個外部Dll,只有一個Dll文件和該Dll的一段說明!
請高手進來,看看如何調用這個DLL?分不夠可加!!!Dll文件名:dbx32sql.dll
Dll文件說明如下:To use this you have one of two constructors to use. Please see example execution below.string dbName = "Temp_zcgl";string serverName = "172.20.1.107";.string username = "shopfloor";string userpwd = "shopfloor";
/// Using the standard constructor and inputing all information
/// From the constructor.  This will automatically instantiate the setConnection Member
 private dbx32sql.Connect conn = new dbx32sql.Connect(dbName, serverName, username, userpwd);/// Using the non standard constructor with no inputs. Must initiate setConnection;private dbx32sql.Connect conn = new dbx32sql.Connect();
conn.Database = dbName;
conn.Server = serverName;
conn.username = username;
conn.userpwd = userpwd;
conn.setConnection; 
try
{
    if (conn.Open)
    {
        string sqlGet = "SELECT COUNT (ID) FROM authors";
        SqlCommand cmdGet = new SqlCommand(sqlGet, conn.Connection);
        int Count = (int)cmdGet.ExecuteScalar();
        CmdGet.Dispose();
    }
    else
    {
        // Input your error handling here;
    }
}
catch(Exception ex)
{
    //insert other error handling.
}
finally
{
    conn.Close();
}請高手進來,看看如何調用這個DLL?分不夠可加!!!

解决方案 »

  1.   

    例子用的是Java吗?
    函数接口声明在什么地方?找到那个先!
      

  2.   

    例子DLL是用.NET寫的(如下)
    /****************************************************
     * File Name: dbx32sql.dll
     * Class Name: Connect
     * Description:
     * Public Members of IsOpen(), Open() and Close() - 
     * each of these items will do it's seperate function
     * IsOpen():
     * Determins if the Connection State of m_conn is Open returns
     * a boolean for determination.
     * 
     * Open():
     * Firsts check to see if the connection state of m_conn is open,
     * then if it's not it opens the connection of m_conn,
     * returns true to say that it is open.
     * 
     * Close():
     * First determins if the connection state is open or closed,
     * If it's open then it will Close the connection
     * Returns true to say that the connection has been closed
     * 
     * Date of Creation: 9/8/05
     * Update by Nicholas: 5/11/07
     ****************************************************/using System;
    using System.Data;
    using System.Data.SqlClient;
    using System.Windows.Forms;
    using System.Diagnostics;
    using System.Security.Permissions;
    using System.Security.Principal;namespace dbx32sql
    {
    /// <summary>
    /// Database connection manipulation.
    /// </summary>
    public class Connect
    {
    #region Private Variables private string database; // Database name inputed from program.
    private string server; // Server name - Is set up in the setup program, and is recalled by the program
            private string username;        // The Sql Authentication Userame
    private string userpwd; // The Sql Authentication Password
    private SqlConnection m_conn;   // Sql Database Connection parameter.
    private string connectionString; // The string used by m_conn for the DB Connection #endregion #region Constructors /// <summary>
    /// Constructor - Input Server name, Database name, Username and password
    /// </summary>
            public Connect(string _database, string _server, string _username, string _userpwd)
    {
    this.database = _database;
    this.server = _server;
                this.username = _username;
                this.userpwd = _userpwd;
    this.setConnection();
    } /// <summary>
    /// Standard Constructor - No Inputs, allows to set inputs by calling ConDb for
    /// Connect Database; ConServ for Connection.server; ConUser for Connection.userpassword;
    /// </summary>
    public Connect()
    { } #endregion #region Public Members
            /// <summary>
            /// Returns the SqlConnection m_conn
            /// </summary>
            public bool FindRecord(string workstation, string sn)
            {
                bool FindRecord = false;
                string sqlstr = "select count(dataid) from shopfloor_datainterchange where workstation =" + "'" + workstation.ToUpper().Trim() + "' and sn =" +
                    "'" + sn.ToUpper().Trim() + "'";
                SqlCommand cmdGet = new SqlCommand(sqlstr, m_conn);
                int Count = (int)cmdGet.ExecuteScalar();
                if (Count >= 1)
                {
                    FindRecord = true;
                }
                else
                {
                    FindRecord = false;
                }
                return FindRecord;
            } /// <summary>
    /// Determine if the Connection State of m_conn is open.
    /// No Inputs.
    /// </summary>
    /// <returns>true if state = open; false if state = closed;</returns>
    public bool IsOpen()
    {
    if (m_conn.State == ConnectionState.Open)
    {
    return true;
    }
    else
    {
    return false;
    }
    } /// <summary>
    /// Opens the database connection.
    /// </summary>
    /// <returns>boolean true</returns>
    public bool Open()
    {
    bool Opened = false;
    try
    {
    if (IsOpen())
    {
    Opened = true;
    }
    else
    {
    m_conn.Open();
    Opened = true;
    }
    return Opened;
    }
    catch(Exception ex)
    {
    this.errTrack(ex);
    this.MessageError();
    }
    return Opened;
    } /// <summary>
    /// Closes the connection to the database.
    /// </summary>
    /// <returns>boolean true;</returns>
    public bool Close()
    {
    bool Closed = false;
    try
    {
    if (IsOpen())
    {
    m_conn.Close();
    Closed = true;
    }
    else
    {
    Closed = true;
    }
    }
    catch(Exception ex)
    {
    this.errTrack(ex);
    this.MessageError();
    }
    return Closed;
    } public void setConnection()
    {
                connectionString = string.Format("Data Source={0};Initial Catalog={1};User ID={2};Password={3}", server, database, username, userpwd);
    m_conn = new SqlConnection(connectionString);
    } #endregion #region Private Members private void errTrack(Exception ex)
    {
    string[] computer = WindowsIdentity.GetCurrent().Name.ToString().Split('\\'); if (!EventLog.SourceExists("sqlConnection"))
    {
    EventLog.CreateEventSource("sqlConnection", "db error", computer[0]);
    } EventLog evntLog = new EventLog();
    evntLog.Source = "sqlConnection";
    evntLog.WriteEntry("Error 1005\n\n" + ex.Message, EventLogEntryType.Error);
    evntLog.Close();
    } private void MessageError()
    {
    DialogResult dlg = MessageBox.Show("Error 1005:\n\nDatabase error. Please see your Event Log for more information.", "Error 1005", MessageBoxButtons.OK, MessageBoxIcon.Error);
    } #endregion #region Public Delegates /// <summary>
    /// Returns the SqlConnection m_conn
    /// </summary>
    public SqlConnection Connection
    {
    get{ return m_conn; }
    }

    /// <summary>
    /// Gets or sets the value for the database name
    /// </summary>
    public string Database
    {
    get{ return database; }
    set{ database = value; }
    } /// <summary>
    /// gets or sets the value for the server name
    /// </summary>
    public string Server
    {
    get{ return server; }
    set{ server = value; }
    }        /// <summary>
            /// gets or sets the value for the server name
            /// </summary>
            public string Username
            {
                get { return username; }
                set { username = value; }
            } /// <summary>
    /// Gets or sets the value for the SAPWD password
    /// </summary>
            public string Userpwd
    {
                get { return userpwd; }
                set { userpwd = value; }
    } #endregion
    }
    }
    如何用Delphi調用這個dbx32sql.dll?