您的位置首页百科问答

VB中的datagrid控件怎么用代码跟adodc的数据连接

VB中的datagrid控件怎么用代码跟adodc的数据连接

adodc.refresh

set datagrid.datasource=adodc

试试

数据库连接

Public Sub connectionDB()

Try

serverUrl = readFromIni(My.Application.Info.DirectoryPath & "\config.dll", "Service Information", "IPAddress")

serverID = readFromIni(My.Application.Info.DirectoryPath & "\config.dll", "Service Information", "Password")

serverName = readFromIni(My.Application.Info.DirectoryPath & "\config.dll", "Service Information", "userID")

serverDataBase = readFromIni(My.Application.Info.DirectoryPath & "\config.dll", "Service Information", "DataBaseName")

If serverID <> "" Then

connectionSqlString = "server =" + serverUrl + ";Database=" + serverDataBase + ";uid =" + serverName + ";pwd=" + serverID + ";max pool size=500"

Else

connectionSqlString = "server =" & serverUrl & ";integrated security = SSPI ;database = " & serverDataBase & ""

End If

conSql = New SqlConnection(connectionSqlString)

objCommand.Connection = conSql

Catch ex As Exception

MsgBox(ex.Message)

End Try

End Sub

'代码连接数据库:

Private Sub Form_Load()

Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\hed.mdb;Persist Security Info=False"

Adodc1.RecordSource = "killv"'表名killv

Adodc1.Refresh

End Sub

datagrid 绑定数据源 为adodc1 属性里设置~