本文介绍了语法错误在查询表达式中缺少运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
String typeoftrans = comboBox1_TransactionType.Text.ToString();
String ondate = DateTime.Now.ToString();
string desc = textBox2_Description.Text.ToString();
string amnt = textBox3_Amount.Text.ToString();
try
{
con.Open();
string Sql = "insert into Account_Transactions(TransactionType,Description,Amount,OnDateTime) values('" +typeoftrans+ ",'" + desc + "','" + amnt + "','" + ondate + "')";
OleDbCommand cmd1 = new OleDbCommand(Sql, con);
int temp = cmd1.ExecuteNonQuery();
if (temp > 0)
{
MessageBox.Show("Transaction done!");
}
else
MessageBox.Show("error");
}
catch (Exception e2)
{
MessageBox.Show(e2.ToString());
}
finally
{
con.Close();
}
推荐答案
values('" +typeoftrans+ ",'"
您在值之前打开报价但是只有在逗号后才能关闭...
You are opening a quote before the value but closing it only after the comma...
这篇关于语法错误在查询表达式中缺少运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!