visual studio 2008 c# dataadapter 无法 实现update 调试时显示select语句错误
publicintAdd(StringStu_ID,StringCourse,doubleScore){StringcommandString="Select*From"...
public int Add(String Stu_ID, String Course,double Score)
{
String commandString = "Select * From " + Course;
String connectionString1 = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=db1.mdb";
OleDbConnection connection = new OleDbConnection(connectionString1);
connection.Open(); //make the link and initialize the adapter
OleDbDataAdapter scoreAdapter = new OleDbDataAdapter(commandString, connectionString1);
DataTable chaxun = new DataTable();
scoreAdapter.Fill(chaxun);
DataRow row = chaxun.NewRow();
row[0] = Stu_ID; row[1] = Score;
chaxun.Rows.Add(row);
OleDbCommandBuilder builder = new OleDbCommandBuilder(scoreAdapter );
scoreAdapter.Update(chaxun);
int i = 1;
return i;
} 展开
{
String commandString = "Select * From " + Course;
String connectionString1 = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=db1.mdb";
OleDbConnection connection = new OleDbConnection(connectionString1);
connection.Open(); //make the link and initialize the adapter
OleDbDataAdapter scoreAdapter = new OleDbDataAdapter(commandString, connectionString1);
DataTable chaxun = new DataTable();
scoreAdapter.Fill(chaxun);
DataRow row = chaxun.NewRow();
row[0] = Stu_ID; row[1] = Score;
chaxun.Rows.Add(row);
OleDbCommandBuilder builder = new OleDbCommandBuilder(scoreAdapter );
scoreAdapter.Update(chaxun);
int i = 1;
return i;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询