using System.Windows.Forms; using System.Data; using MySql.Data.MySqlClient; mySqlConnection2.ConnectionString ="connection timeout=30;server=192.168.8.112;user id=zjmzs; password=zjmzs; port=3306; database=popoface;pooling=true; min pool size=3; max pool size=101"; mySqlConnection2.Open(); MySqlDataAdapter adapter =new MySqlDataAdapter(); adapter.SelectCommand =new MySqlCommand("select * from uploadcfd", mySqlConnection2); adapter.Fill(dataSet1);
using System; using System.Security; using System.Runtime.InteropServices; /**////<summary>Connects to a MySql server</summary> ///<returns><paramref name="db"/> value on success, else returns IntPtr.Zero</returns> [SuppressUnmanagedCodeSecurity] [DllImport("libmySQL.dll", CharSet=System.Runtime.InteropServices.CharSet.Ansi, EntryPoint="mysql_real_connect", ExactSpelling=true)] publicstaticextern IntPtr Connect(IntPtr db, [In] string host, [In] string user, [In] string passwd, [In] string dbname, uint port, [In] string socketName, uint flags ); /**////<summary>Selects a database</summary> ///<returns>Zero for success. Non-zero if an error occurred.</returns> [SuppressUnmanagedCodeSecurity] [DllImport("libmySQL.dll", CharSet=System.Runtime.InteropServices.CharSet.Ansi, EntryPoint="mysql_select_db", ExactSpelling=true)] publicstaticexternint SelectDb(IntPtr conn, [In] string db); /**////<summary>Closes a server connection</summary> [SuppressUnmanagedCodeSecurity] [DllImport("libmySQL.dll", EntryPoint="mysql_close", ExactSpelling=true)] publicstaticexternvoid Close(IntPtr db); /**////<summary>Executes a SQL query specified as a string</summary> ///<returns>number of rows changed, -1 if zero</returns> [SuppressUnmanagedCodeSecurity] [DllImport("libmySQL.dll", CharSet=System.Runtime.InteropServices.CharSet.Ansi, EntryPoint="mysql_query", ExactSpelling=true)] publicstaticexternint Query(IntPtr conn, [In] string query); /**////<summary>Retrieves a complete result set to the client</summary> ///<returns>An IntPtr result structure with the results. IntPtr.Zero if an error occurred.</returns> [SuppressUnmanagedCodeSecurity] [DllImport("libmySQL.dll", EntryPoint="mysql_store_result", ExactSpelling=true)] publicstaticextern IntPtr StoreResult(IntPtr conn); /**////<returns>Returns the number of rows in a result set</returns> [SuppressUnmanagedCodeSecurity] [DllImport("libmySQL.dll", EntryPoint="mysql_num_rows", ExactSpelling=true)] publicstaticexternint NumRows(IntPtr r); /**////<returns>Returns the number of columns in a result set</returns> [SuppressUnmanagedCodeSecurity] [DllImport("libmySQL.dll", EntryPoint="mysql_num_fields", ExactSpelling=true)] publicstaticexternint NumFields(IntPtr r);