注册 登录
编程论坛 SQL Server论坛

SQL删除表的问题...新手

whise178com 发布于 2011-09-03 00:42, 342 次点击
程序代码:
int of = dataGridView1.CurrentRow.Index;
            dataGridView1.Rows.RemoveAt(of);
            string str="delete from Table5 where IID="+of+"";
            SqlCommand com = new SqlCommand(str, con);
            SqlDataAdapter data = new SqlDataAdapter();
            data.DeleteCommand = com;
            //data.Update(ds);
            MessageBox.Show("删除成功!", "消息", MessageBoxButtons.OK);
只能删除dataGridBiew1的显示的数据,实际表里的没有删除,这里哪里有问题?
2 回复
#2
tangyunzhong2011-09-03 16:47
回复 楼主 whise178com
你后面写错了,给你个参考的:

this.da = new SqlDataAdapter(this.strSQL,this.myConnection);
            this.sqlCmdBld = new SqlCommandBuilder(da);
            this.da.Update(changedDataSet,tableName);
#3
cnfarer2011-09-03 18:54
SqlDataAdapter 根本没连到数据库,有什么用。
1