62,046
社区成员
发帖
与我相关
我的任务
分享
public DataTable GetDataTable()
{
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Mike\DAOWebTest\App_Data\Northwind.mdb;User Id=;Password=;";
DataTable dt = new DataTable();
OleDbConnection conn = new OleDbConnection(connectionString);
OleDbCommand oledbCmd = new OleDbCommand("select * from Products where [類別]=@kind",conn);
oledbCmd.CommandType = CommandType.Text;
oledbCmd.Parameters.AddWithValue("@kind", "飲料");
OleDbDataAdapter oledbDa = new OleDbDataAdapter(oledbCmd);
oledbDa.Fill(dt);
return dt;
}
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\Mike\\DAOWebTest\\App_Data\\Northwind.mdb;User Id=;Password=;";
OleDbConnection conn = new OleDbConnection(connectionString);
OleDbCommand oledbCmd = new OleDbCommand("select * from Products where [類別]=?",conn);
oledbCmd.CommandType = CommandType.Text;
oledbCmd.Parameters.AddWithValue("kind", "飲料");
OleDbDataAdapter oledbDa = new OleDbDataAdapter(oledbCmd);
DataSet ds = new DataSet();
oledbDa.Fill(ds,"Products");
DataTable dt = ds.Tables[0];
return dt;
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\Mike\\DAOWebTest\\App_Data\\Northwind.mdb;User Id=;Password=;";
OleDbConnection conn = new OleDbConnection(connectionString);
OleDbCommand oledbCmd = new OleDbCommand("select * from Products where [類別]=@kind",conn);
oledbCmd.CommandType = CommandType.Text;
oledbCmd.Parameters.AddWithValue("@kind", "飲料");
OleDbDataAdapter oledbDa = new OleDbDataAdapter(oledbCmd);
DataSet ds = new DataSet();
oledbDa.Fill(ds,"Products");
DataTable dt = ds.Tables[0];
return dt;
public DataTable GetDataTable()
{
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Mike\DAOWebTest\App_Data\Northwind.mdb;User Id=;Password=;";
OleDbConnection conn = new OleDbConnection(connectionString);
OleDbCommand oledbCmd = new OleDbCommand("select * from Products where [類別]=@kind",conn);
oledbCmd.CommandType = CommandType.Text;
oledbCmd.Parameters.AddWithValue("@kind", "飲料");
OleDbDataAdapter oledbDa = new OleDbDataAdapter(oledbCmd,conn);
DataSet ds = new DataSet();
oledbDa.Fill(ds,"Products");
DataTable dt = ds.Table[0].DefultView;
return dt;
}