vb中adodc和datagrid控件的用法
DimmyconAsNewADODB.ConnectionDimmycomAsNewADODB.CommandDimmyrecAsNewADODB.Recordsetmy...
Dim mycon As New ADODB.Connection
Dim mycom As New ADODB.Command
Dim myrec As New ADODB.Recordset
mycon.ConnectionString = "provider=microsoft.jet.oledb.3.51;" & "data source=f:\mysany\qq1.mdb"
mycon.Open
STR1 = "select * from 表1"
set mycom.ActiveConnection = mycon
myrec.CommandText = STR1
Set myrec = mycom.Execute
datagrid1的数据源已经指向了adodc1
但现在运行后datagrid1中没有一个数据.我就想通过全代码编写使adodc1控件连接到一个sql查询语言的表,在datagrid1表格中显示出来.希望有会的能给出代码, 展开
Dim mycom As New ADODB.Command
Dim myrec As New ADODB.Recordset
mycon.ConnectionString = "provider=microsoft.jet.oledb.3.51;" & "data source=f:\mysany\qq1.mdb"
mycon.Open
STR1 = "select * from 表1"
set mycom.ActiveConnection = mycon
myrec.CommandText = STR1
Set myrec = mycom.Execute
datagrid1的数据源已经指向了adodc1
但现在运行后datagrid1中没有一个数据.我就想通过全代码编写使adodc1控件连接到一个sql查询语言的表,在datagrid1表格中显示出来.希望有会的能给出代码, 展开
1个回答
2013-11-10
展开全部
你试试~ 以前我用的代码,应该可以的~~
Private Sub Form_Load()
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=f:\mysany\qq1.mdb;Persist Security Info=False"
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from 表1"
Set DataGrid1.DataSource = Adodc1
Me.Refresh
End Sub
Private Sub Form_Load()
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=f:\mysany\qq1.mdb;Persist Security Info=False"
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from 表1"
Set DataGrid1.DataSource = Adodc1
Me.Refresh
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询