刚开始学数据库 仿照书上写程序 出现了问题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条件有限 只能自学 请大家帮帮没忙

解决方案 »

  1.   

    Dim i As Integer
    Dim a As Integer Adodc1.Refresh
     Adodc1.RecordSource = "select * from tabel1 " & "where id = Val(form2.Text1.Text) "
     DataGrid1.ColumnHeaders = True
     DataGrid1.ReBind
     DataGrid1.Refresh
      

  2.   

    Dim i As Integer
    Dim a As Integer Adodc1.Refresh
     Adodc1.RecordSource = "select * from tabel1 " & "where id = Val(form2.Text1.Text) "
     DataGrid1.ColumnHeaders = True
     DataGrid1.ReBind
     DataGrid1.Refresh
    是不是应该这样子写 而不用去先打开数据库啊 可是出来结果不对啊
      

  3.   

    Adodc1.RecordSource = "select * from tabel1 where id = " & Val(form2.Text1.Text)
      

  4.   

    '使用ADO连接Access
    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
      

  5.   

    sql="select * from tabel1 " & "where id = " & Val(form2.Text1.Text) 
    你把它解析出来看看,再对照数据库看看
      

  6.   

    哦 好了 
    谢谢各位
    又发现一个问题我是command4_click()执行这些的
    现在只是可以执行一次查询我再次按下command4
    它就出错了这该怎么处理啊?
      

  7.   

    是不是我没讲清楚啊 我想在text1.text中输入一个有效值之后 command4_click() 进行查询现在的问题是 只能查询一次 比如我开始text1.text=106  查询完之后 
    我将text1.text=1002 再次查询 结果出来的还是106的结果哪里的问题啊?自学真的很痛苦啊真是无奈啊千万别沉了
      

  8.   

    你能将工程文件发我看一下吗?QQ:378268084请注明csdn
      

  9.   

    建议将数据库关闭后再用form_load()刷新一下就可以了,我以前都是这么做的