刚开始学数据库 仿照书上写程序 出现了问题form2.text1.text中输入某个有效值
然后在form3的DataGrid1中将 id=form2.text1.text 的那些记录显示出来Dim i As Integer
Dim a As Integer
Dim myRs As New ADODB.Recordset
Dim conn As New ADODB.ConnectionsPath = App.Path & "\wendu.mdb" conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & sPath & " ';Persist Security Info=False"
myRs.CursorLocation = adUseClient
myRs.Open "select * from tabel1" & "where id = Val(form2.Text1.Text) ", conn, 1, 3
'''''''错误 不会写 Adodc1.Refresh
Adodc1.RecordSource = "select * from tabel1 " & "where id = Val(form2.Text1.Text) "
DataGrid1.ColumnHeaders = True
DataGrid1.ReBind
DataGrid1.Refresh条件有限 只能自学 请大家帮帮没忙
然后在form3的DataGrid1中将 id=form2.text1.text 的那些记录显示出来Dim i As Integer
Dim a As Integer
Dim myRs As New ADODB.Recordset
Dim conn As New ADODB.ConnectionsPath = App.Path & "\wendu.mdb" conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & sPath & " ';Persist Security Info=False"
myRs.CursorLocation = adUseClient
myRs.Open "select * from tabel1" & "where id = Val(form2.Text1.Text) ", conn, 1, 3
'''''''错误 不会写 Adodc1.Refresh
Adodc1.RecordSource = "select * from tabel1 " & "where id = Val(form2.Text1.Text) "
DataGrid1.ColumnHeaders = True
DataGrid1.ReBind
DataGrid1.Refresh条件有限 只能自学 请大家帮帮没忙
Dim a As Integer Adodc1.Refresh
Adodc1.RecordSource = "select * from tabel1 " & "where id = Val(form2.Text1.Text) "
DataGrid1.ColumnHeaders = True
DataGrid1.ReBind
DataGrid1.Refresh
Dim a As Integer Adodc1.Refresh
Adodc1.RecordSource = "select * from tabel1 " & "where id = Val(form2.Text1.Text) "
DataGrid1.ColumnHeaders = True
DataGrid1.ReBind
DataGrid1.Refresh
是不是应该这样子写 而不用去先打开数据库啊 可是出来结果不对啊
ConnectionString="PROVIDER=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:System database=SYSTEM.MDW;Data Source=DBName.mdb"
cn.Open ConnectionString'myRs.Open "select * from tabel1" & "where id = Val(form2.Text1.Text) ", conn, 1, 3
sql="select * from tabel1 " & "where id = " & Val(form2.Text1.Text)
myRs.CursorLocation = adUseClient
myRs.Open sql, cn, adOpenDynamic, adLockOptimisticSet DataGrid1.DataSource=myRs
你把它解析出来看看,再对照数据库看看
谢谢各位
又发现一个问题我是command4_click()执行这些的
现在只是可以执行一次查询我再次按下command4
它就出错了这该怎么处理啊?
我将text1.text=1002 再次查询 结果出来的还是106的结果哪里的问题啊?自学真的很痛苦啊真是无奈啊千万别沉了