62,074
社区成员
发帖
与我相关
我的任务
分享
public static int getMySqlInsertMsSql()
{
MySQLConnection conn = null;
try
{
string connstr = "Data Source=source;Password=pass;User ID=name;Location=202.181.244.114";
conn = new MySQLConnection(connstr);
conn.Open();
//在mysql数据库测试结果为12条
string query = "select * from orders where date_purchased > '2010-2-4 12:00:00'";
MySQLCommand comm = new MySQLCommand(query, conn);
//MySQLDataReader reader = comm.ExecuteReaderEx();
MySQLDataAdapter adapter = new MySQLDataAdapter(comm);
DataSet ds = new DataSet();
//走到这步抛出异常!!!!!!!!!!!!!!!
adapter.Fill(ds);
DataTable table = ds.Tables[0];
int a = 0;
IList<Orders> list = new List<Orders>();
foreach (DataRow row in table.Rows)
{
Orders orders = new Orders();
orders.Ordernum = row["orders_id"].ToString();
list.Add(orders);
a++;
}
comm.Dispose();
conn.Close();
return a;
}
catch (Exception e)
{
e.Message.ToString();
}
finally
{
conn.Close();
}
return 0;
}