dconnetion = New OdbcConnection(lsconnectionstring)
dconnetion.Open()
mssql = "select cust_id,cust_name,cust_address,cust_contact_no from cust_details where cust_id in (select cust_id from cust_details)"
cmd.Connection = dconnetion
cmd.CommandText = mssql
cmd.CommandType = CommandType.Text
dr = cmd.ExecuteReader
我使用此语句使用DataReader从数据库中读取数据。
问题在于,当我使用DataSet而不是DataReader时,查询是什么?
答案 0 :(得分:0)
使用DataAdapter.Fill()
方法使用相同的查询。
dconnetion = new OdbcConnection(lsconnectionstring);
//dconnetion.Open()
mssql = "select cust_id,cust_name,cust_address,cust_contact_no from cust_details where cust_id in (select cust_id from cust_details)";
cmd.Connection = dconnetion;
cmd.CommandText = mssql;
cmd.CommandType = CommandType.Text;
using (OdbcDataAdapter da = new OdbcDataAdapter(cmd))
{
DataSet ds = new DataSet();
dconnetion.Open();
da.Fill(ds);
dconnetion.Close();
}