展开全部
Dim myConn As Data.OleDb.OleDbConnection
myConn = New System.Data.OleDb.OleDbConnection()
myConn.ConnectionString = strCon
myConn.Open()
Dim sqldel As String = "delete from Table where AAA='"&datagridview1.CurrentRow.Cells(i).Value.ToString.Trim()&"'
Dim del As OleDbCommand = New OleDbCommand(sqldel, myConn)
del.ExecuteNonQuery()
myConn.Close
然后再重新帮顶下datatable显示一下就ok了
myConn = New System.Data.OleDb.OleDbConnection()
myConn.ConnectionString = strCon
myConn.Open()
Dim sqldel As String = "delete from Table where AAA='"&datagridview1.CurrentRow.Cells(i).Value.ToString.Trim()&"'
Dim del As OleDbCommand = New OleDbCommand(sqldel, myConn)
del.ExecuteNonQuery()
myConn.Close
然后再重新帮顶下datatable显示一下就ok了
追问
你能解释一下吗,我有点看不懂,我想问这是vb.net版的吗
追答
是的,
myConn = New System.Data.OleDb.OleDbConnection()
myConn.ConnectionString = strCon
myConn.Open() ‘连接数据库
Dim sqldel As String = "delete from Table where AAA='"&datagridview1.CurrentRow.Cells(i).Value.ToString.Trim()&"' ’sql语句
Dim del As OleDbCommand = New OleDbCommand(sqldel, myConn)
del.ExecuteNonQuery() ‘执行sql语句
myConn.Close ’关闭数据库
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询