使用VB+SQL做C/S系统时.使用Adodc+DataGrid动态绑定数据表,不知道为什么只能在本机显示数据,在其它机上没有数据呢?其它数据都正常.就差这一个地方了.哪位高手帮帮俺.3Q~~`动态绑定:
    adoLXX.ConnectionString = CN.ConnectionString
    adoLXX.CommandType = adCmdText
    adoLXX.RecordSource = "Select * From test Where lh='02480001' Order By id"
    adoLXX.Refresh

解决方案 »

  1.   

    dim rs as new adodb.recordset
    dim strsql as string
    if rs.state=adstateopen then rs.close
    strsql=" select * from test where lh='02480001' order by id"
    rs.open strsql,cn,adopenkeyset,adlockreadonly
    set datagrid.datasource=rs
    rs.close
    set rs=nothing
      

  2.   

    adoLXX.ConnectionString = CN.ConnectionString?看一看你的连接代码可能是你的数据库存放的位置与本机不一致了,而不能正确显示数据。
      

  3.   

    给左手兄+上数据库连接con.ConnectionString = "Provider=SQLOLEDB.1;Password=123;Persist Security Info=True;User ID=sa;Initial Catalog=aa;Data Source=qq"
    con.CursorLocation = adUseClient
    con.Open
      

  4.   

    左手的代码当然是错误的,rs都close掉了,怎么会有数据呢?左手,一定没有仔细思考就回答的^^笑笑没有数据大概是你用adodc已经定死了数据库的位置只要把adodc控件的连接字符重新写,用app.path定向就好了
    Option ExplicitPrivate Sub Form_Load()
      With Me.Adodc1
        .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Man.mdb;Persist Security Info=False"
        .RecordSource = "select * from Man"
        Set Me.DataGrid1.DataSource = Me.Adodc1
      End With
    End Sub这样样子就可以了