vb.net 中如何使用SQL语句查询数据库 50
我从工具栏中拖OleDbDataAdapter1控件到窗体上用向导连接ACCESS数据库后生成OleDbConnection1然后生成DataSet1。之后在窗体上放个D...
我从工具栏中拖OleDbDataAdapter1控件到窗体上用向导连接ACCESS数据库后生成OleDbConnection1然后生成DataSet1。之后在窗体上放个DataGrid1将其DataSource属性设为DataSet11.表1用来显示数据。现在要执行SQL语句"Select * from 表1 Where 姓名=小强"该怎么办啊??请指教谢谢。
(只采纳解答比较详细的,代码解释清楚的。)
用的是vb2003 展开
(只采纳解答比较详细的,代码解释清楚的。)
用的是vb2003 展开
2个回答
展开全部
我是这样做的:
Dim ConnectionString As String = _
"Provider=Microsoft.Jet.OleDb.4.0;_DatacSource = App.Path+\temp.mdb"
Dim myconn As OleDbConnection = New OleDbConnection()
myconn.ConnectionString = ConnectionString
Dim strcom As String = "select * form 通讯录"
OleDbConnection1.Open()
Dim strdele As String="DELTEL 表 WHERE 姓名='MMM'"
Dim mycommand As OleDbCommand = New OleDbCommand(strdele, myconn)
mycommand.ExecuteNonQuery() '从数据库中删除记录
DataSet1.Tables("通讯录").Rows(mybind.Position).Delete() '逻辑删除
DataSet1.Tables("通讯录").AcceptChanges()
OleDbConnection1.Close()
Dim ConnectionString As String = _
"Provider=Microsoft.Jet.OleDb.4.0;_DatacSource = App.Path+\temp.mdb"
Dim myconn As OleDbConnection = New OleDbConnection()
myconn.ConnectionString = ConnectionString
Dim strcom As String = "select * form 通讯录"
OleDbConnection1.Open()
Dim strdele As String="DELTEL 表 WHERE 姓名='MMM'"
Dim mycommand As OleDbCommand = New OleDbCommand(strdele, myconn)
mycommand.ExecuteNonQuery() '从数据库中删除记录
DataSet1.Tables("通讯录").Rows(mybind.Position).Delete() '逻辑删除
DataSet1.Tables("通讯录").AcceptChanges()
OleDbConnection1.Close()
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询