C# 运行后提示 语法错误(操作符丢失)在查询表达式中 5
求救呀..c#研究生管理信息系统添加成绩模块....运行后报语法错误(操作符丢失)在查询表达式中OleDbConnectionOleConnection1=newOleD...
求救呀..c#研究生管理信息系统添加成绩模块....运行后报 语法错误(操作符丢失)在查询表达式中
OleDbConnection OleConnection1 = new OleDbConnection(Database.Dbconnection.ConnectionString);
OleConnection1.Open();
string sql;
sql = "select * from scoreinfo where SID='" + ComboSName.SelectedValue.ToString().Trim() + "'and CName='" + ComboCName.Text.Trim() + "'";
OleDbCommand cmd = new OleDbCommand(sql, OleConnection1);
if (null == cmd.ExecuteScalar())
{
sql = "insert into scoreinfo (SID,CName,Score) values ('" + ComboSName.SelectedValue.ToString().Trim() + "','" + "'" + ComboCName.Text.Trim() + "','" + TextScore.Text.Trim() + "')";
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
MessageBox.Show("成绩添加成功", "提示");
this.TextScore.Clear();
}
else
MessageBox.Show("在同一个学生不能添加相同的课程的成绩", " 提示");
OleConnection1.Close(); 展开
OleDbConnection OleConnection1 = new OleDbConnection(Database.Dbconnection.ConnectionString);
OleConnection1.Open();
string sql;
sql = "select * from scoreinfo where SID='" + ComboSName.SelectedValue.ToString().Trim() + "'and CName='" + ComboCName.Text.Trim() + "'";
OleDbCommand cmd = new OleDbCommand(sql, OleConnection1);
if (null == cmd.ExecuteScalar())
{
sql = "insert into scoreinfo (SID,CName,Score) values ('" + ComboSName.SelectedValue.ToString().Trim() + "','" + "'" + ComboCName.Text.Trim() + "','" + TextScore.Text.Trim() + "')";
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
MessageBox.Show("成绩添加成功", "提示");
this.TextScore.Clear();
}
else
MessageBox.Show("在同一个学生不能添加相同的课程的成绩", " 提示");
OleConnection1.Close(); 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询