【发布时间】:2013-06-27 14:09:43
【问题描述】:
当我尝试向表 pay_cheque 插入任何帮助时出现此错误
private void btnadd_Click(object sender, EventArgs e)
{
string s = "insert into pay_cheque values('Sai','Sai','Sai','Sai','10.2','1989/2/3','Sai')";
SqlConnection con = new SqlConnection("server=.;Data Source=.;Initial Catalog=Book;Integrated Security=True");
SqlDataAdapter da = new SqlDataAdapter(s, con);
DataSet ds = new DataSet();
da.Fill(ds, "x");
dataGridView1.DataSource = ds.Tables[0];
}
【问题讨论】:
-
有一段时间没有使用
SqlDataAdapter,但是您为什么要尝试使用插入命令填充新创建的DataSet?你不想使用现有的DataSet吗? -
我没听懂你,但是当我使用命令对象时它正在工作
-
尝试使用名称而不是索引 0。
-
是的,它的工作原理你能告诉我为什么我得到这个错误
标签: sql datagridview dataset dataadapter