主题:小弟不才,问大家一个很简单的问题,请哥哥姐姐们指点
初始化
这是我编的有关数据库的程序
......
string myConnString="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=model";
string mySelectQuery="SELECT N,DrugName,DrugAmount FROM DrugData where DrugName=@Name";
SqlConnection myConnection = new SqlConnection(myConnString);
SqlDataAdapter myDataAdapter = new SqlDataAdapter(mySelectQuery,myConnection);
......
if(this.textBox2.Text!="")
{
myDataAdapter.SelectCommand.Parameters.Add(new SqlParameter("@Name",SqlDbType.NVarChar,10));
myDataAdapter.SelectCommand.Parameters["@Name"].Value=this.textBox2.Text;
//myDataAdapter.;
myDataAdapter.Fill(ds,"test");
amount2=int.Parse(ds.Tables["test"].Rows[0][2].ToString());
amount2=amount2-int.Parse(this.textBox17.Text);
}
......
因为"myDataAdapter"被我重复使用,所以系统的提示是:myDataAdapter再次调用未初始化,所以我想请问大家它的初始化函数是什么,谢谢。
这是我编的有关数据库的程序
......
string myConnString="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=model";
string mySelectQuery="SELECT N,DrugName,DrugAmount FROM DrugData where DrugName=@Name";
SqlConnection myConnection = new SqlConnection(myConnString);
SqlDataAdapter myDataAdapter = new SqlDataAdapter(mySelectQuery,myConnection);
......
if(this.textBox2.Text!="")
{
myDataAdapter.SelectCommand.Parameters.Add(new SqlParameter("@Name",SqlDbType.NVarChar,10));
myDataAdapter.SelectCommand.Parameters["@Name"].Value=this.textBox2.Text;
//myDataAdapter.;
myDataAdapter.Fill(ds,"test");
amount2=int.Parse(ds.Tables["test"].Rows[0][2].ToString());
amount2=amount2-int.Parse(this.textBox17.Text);
}
......
因为"myDataAdapter"被我重复使用,所以系统的提示是:myDataAdapter再次调用未初始化,所以我想请问大家它的初始化函数是什么,谢谢。