在调用“Fill”前,SelectCommand 属性尚未初始化
privatevoidbutton1_Click(objectsender,EventArgse){StringConnStr="Provider=Microsoft.J...
private void button1_Click(object sender, EventArgs e)
{
String ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Documents and Settings\\Administrator\\桌面\\db3.mdb";
OleDbConnection myCon = new OleDbConnection(ConnStr);
myCon.Open();
DataTable ReaderTable = new DataTable();
string CMDstring = "Select 读者姓名,年级 From 登录AND读者信息 WHERE 读者编号=@" + this.textBox1.Text;
OleDbCommand CMD = new OleDbCommand(CMDstring,myCon);
CMD.CommandType=CommandType.Text;
OleDbDataAdapter DA = new OleDbDataAdapter();
DA.Fill(ReaderTable);
this.textBox2.Text = ReaderTable.Rows[0][0].ToString();
this.textBox3.Text = ReaderTable.Rows[0][1].ToString();
}
其中的Access文件为
读者编号 读者姓名 年级 展开
{
String ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Documents and Settings\\Administrator\\桌面\\db3.mdb";
OleDbConnection myCon = new OleDbConnection(ConnStr);
myCon.Open();
DataTable ReaderTable = new DataTable();
string CMDstring = "Select 读者姓名,年级 From 登录AND读者信息 WHERE 读者编号=@" + this.textBox1.Text;
OleDbCommand CMD = new OleDbCommand(CMDstring,myCon);
CMD.CommandType=CommandType.Text;
OleDbDataAdapter DA = new OleDbDataAdapter();
DA.Fill(ReaderTable);
this.textBox2.Text = ReaderTable.Rows[0][0].ToString();
this.textBox3.Text = ReaderTable.Rows[0][1].ToString();
}
其中的Access文件为
读者编号 读者姓名 年级 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询