别用绑定方式。在连接字符串里设置密码。至于字符串是什么样子,你用Data控件可以自动获取。试试

解决方案 »

  1.   

    不明白你的意思。不用绑定我也会写,比较麻烦。难道Data不能处理密码?
      

  2.   

    CommonDialog1.ShowOpen
    strFileName = CommonDialog1.FileName
    Set dbsCus = OpenDatabase(strFileName)
    Set rstCus = dbsCus.OpenRecordset("入库登记表")
    MsgBox rstCus.RecordCount
    //--------------------------------------------------
    就不说上面的问题了,现在我想把rstCus里的记录放到一个Grid里,怎么设置Grid的属性,用哪个Grid好呢?为什么MsgBox 显示的记录是“1”呢,明明我的表里有很多记录嘛。
      

  3.   

    实在不想回答了,其实有很多东西可以代替DBGRID的, 我一般喜欢listview  
    你这样做好了
    Dim dat As Database
    Dim r As Recordset
    Set dat = OpenDatabase("f:\temp.mdb")
    Set r = dat.OpenRecordset("codesize")
    Set Data1.Recordset = r
    DBGrid1.DataSource = Data1
    Data1.Refresh
    DBGrid1.Refresh
      

  4.   

    谢谢楼上的大虾,不过这段代码你试过吗?
    当我运行到DBGrid1.DataSource = Data1时,出现这样的错误提示:
    //------------------------------------------------------
    实时错误,‘430’
    类不支持自动化或不支持期望的接口
    //------------------------------------------------------
    我给你看一下我改写的:
    Option Explicit
    Dim dat As Database
    Dim r As Recordset
    Dim strFileName As StringPrivate Sub Command1_Click()
    CommonDialog1.ShowOpen
    strFileName = CommonDialog1.FileName
    Set dat = OpenDatabase(strFileName)
    Set r = dat.OpenRecordset("信息表")
    Set Data1.Recordset = r
    DBGrid1.DataSource = Data1
    Data1.Refresh
    DBGrid1.Refresh
    End Sub
      

  5.   

    哈哈,,,还是要谢谢_1_(到jinesc.6600.org来找我) 。我把出现错误的那句删掉了,好了。再次感谢!
    不过还有个问题,上面提到:为什么MsgBox 显示的记录是“1”呢?
    我先movefirst,接着movelast,又movefirst,这个时候显示的就是实际的记录数了,真奇怪!
      

  6.   

    http://expert.csdn.net/Expert/topic/709/709735.xml?temp=.7223322
      

  7.   

    哦,谢谢,又学会了一招。上面忘说了,我删掉了那句,并且在DBGfid里指定了Data。现在还剩一个问题了,就是上面提到:为什么MsgBox 显示的记录是“1”呢?我先movefirst,接着movelast,又movefirst,这个时候显示的就是实际的记录数了,真奇怪!
      

  8.   

    这个可以显示记录数
    dim rst as new adodb.recordset
    rst.open sql语句,连接名称,1,1
      

  9.   

    当然你的问题还可以用adodc来解决
    Adodc1.ConnectionString = "provider=......."
    如果直接输入sql的话:
    Adodc1.CommandType = adCmdText
    Adodc1.RecordSource = sql命令
    如果使用存储过程的话:
    Adodc1.CommandType = adCmdStoredProc
    Adodc1.RecordSource = "存储过程名称"
    Adodc1.Refresh
    msgbox adodc1.recordset.recordcount
    Set DataGrid1.DataSource = Adodc1