如何在更新Querry中删除语法错误。 [英] How Can I Remove Syntax Error In Update Querry.
本文介绍了如何在更新Querry中删除语法错误。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码就是代码中的代码总是在update statement中出现语法错误。在我的组合框中,数据从数据库中填充。
code。
my Code is that in that code always occurred syntax error in update statement.in my combo box data is filled from the database.
code.
void shw_group()
{
try
{
s = "select * from create_group";
da = new OleDbDataAdapter(s, cn);
DataSet ds = new DataSet();
da.Fill(ds, "set");
cmb_group_name.DataSource = ds;
cmb_group_name.DisplayMember = "set.group";
}
catch (Exception ea)
{
MessageBox.Show(ea.Message);
}
}
private void button1_Click(object sender, EventArgs e)
{
upd();
}
void upd()
{
string group_name;
group_name = cmb_group_name.Text;
string s = "update persn_info set group ="+group_name+" where sub_no="+ txt_sub_no.Text;
cm = new OleDbCommand(s, cn);
//cm.Parameters.AddWithValue("@group", group_name);
cn.Open();
cm.ExecuteNonQuery();
cn.Close();
MessageBox.Show("Subscriber information is updated", "Di-Count", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
推荐答案
你有传递别名数据集对象名称ds。
所以你有在给出ComboBox控件的数据源时传递该别名
You have pass alias Name of Dataset object ds.
So you have to pass that alias name when you give datasource of ComboBox Control
cmb_group_name.DataSource = ds.Tables["set"];
这篇关于如何在更新Querry中删除语法错误。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文