VB中的datagrid控件怎么用代码跟adodc的数据连接
为什么用控件的时候,adodc连接了数据库,然后datagrid的datasource选择adodc,就可以显示数据库的数据!但我用代码将adodc的值付给datagri...
为什么用控件的时候,adodc连接了数据库,然后datagrid的datasource选择adodc,就可以显示数据库的数据!但我用代码将adodc的值付给datagrid的datasource时会提示出错的呢? 出错的信息为:未找到方法或数据成员!
我是个VB初学者哦!恳切地希望各位爱好者指导一下小弟!感激不尽!~~~ 展开
我是个VB初学者哦!恳切地希望各位爱好者指导一下小弟!感激不尽!~~~ 展开
3个回答
展开全部
数据库连接
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
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 属性里设置~
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 属性里设置~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2009-03-19
展开全部
adodc.refresh
set datagrid.datasource=adodc
试试
set datagrid.datasource=adodc
试试
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询