恭喜,你发布的帖子
发布于 2016-04-04 20:42:14
3楼
还是不太懂啊。
请问万泉河大侠:
我是要在窗口中拖放两个.net控件:AdoDC和DataGrid吗?它们默认的控件名字是不是.Net Control?
下面是我写的代码,数据集加载不到 DataGrid 中,显示不出来,请帮忙看看哪里有问题啊?多谢了!
Sub OnLButtonDown(Byval Item, Byval Flags, Byval x, Byval y)
Dim objConnection
Dim objCommand
Dim objRecordset
Dim strConnectionString
Dim strSQL
strConnectionString = "Provider=MSDASQL;DSN=TX;UID=;PWD=;"
strSQL = "select ID from TX;"
Set objConnection = CreateObject("ADODB.Connection")
objConnection.ConnectionString = strConnectionString
objConnection.Open
Set objRecordset = CreateObject("ADODB.Recordset")
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = strSQL
Set objRecordset = objCommand.Execute
Set DataGrid1.DataSource = Adodc1 '好像是这里开始有问题。
DataGrid1.Refresh
Set objCommand = Nothing
objConnection.Close
Set objRecordset = Nothing
Set objConnection = Nothing
End Sub
Set DataGrid1.DataSource = Adodc1.recordset
请填写推广理由:
分享
只看
楼主