private void UpdataDBData(String myID,String myName)
{
//设置访问数据库的连接
string accessString= ACCESSCONNECTIONSTRING +Server.MapPath("dbfiles//MyFirstAccessDB.mdb").ToString();
//设置更新数据库的SQL语句
string cmdText = "UPDATE MyDataTable SET MyName="+myName+"WHERE MyID=" +myID;
//创建访问数据库的连接&Command
OleDbConnection accessConn = new OleDbConnection(accessString);
OleDbCommand accessComm = new OleDbCommand(cmdText,accessConn);
try
{
accessConn.Open();
accessComm.ExecuteNonQuery();
accessConn.Close();
}
catch(Exception ex)
{
Response.Write(ex.Message);
}
}
private void UpdateDataBtn_Click(object sender, System.EventArgs e)
{
if(MyID.Text.Trim().Length>0 && MyName.Text.Trim().Length>0)
{
UpDataDBData(MyID.Text.Trim(),MyName.Text.Trim());
ShowDBData();
}
}
经过检查发现命名空间的引用集已经引用完毕,困扰了半个小时后,终于发现了函数UpDataDBData(MyID.Text.Trim(),MyName.Text.Trim());
调用时upDataDBData应该是updataDBData,完全是大小写错误!