MSHFlexGrid1和ADODB问题
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
Set cmd = New ADODB.Command
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & App.Path & "\DBEmp.mdb;" & _
"Persist Security Info=False"
conn.Open
cmd.CommandType = adCmdText
cmd.ActiveConnection = conn
cmd.CommandText = "select * from EmpTable"
Set rs = cmd.Execute
Set MSHFlexGrid1.DataSource = rs
rs.Close
conn.Close
结果:只显示1行,实际有多行,不知错在哪?
[解决办法]
Dim cn As New ADODB.Connection Dim rst As New ADODB.Recordset Dim SqlStr As String cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb;Mode=ReadWrite;Persist Security Info=False;Jet OLEDB:Database Password=111" SqlStr = "Select * From EmpTable" rst.CursorLocation = adUseClient rst.Open SqlStr, cn, adOpenDynamic, adLockOptimistic, adCmdText '打开记录集 Set MSHFlexGrid1.DataSource = rst '数据源
[解决办法]
Set conn = New ADODB.Connection Set rs = New ADODB.Recordset 'Set cmd = New ADODB.Command conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & App.Path & "\DBEmp.mdb;" & _ "Persist Security Info=False" conn.Open 'cmd.CommandType = adCmdText 'cmd.ActiveConnection = conn 'cmd.CommandText = "select * from EmpTable" 'Set rs = cmd.Execute if rs.state<>adstateclosed then rs.close rs.open "select * from EmpTable",conn,adopenkeyset,adlockreadonly Set MSHFlexGrid1.DataSource = rs rs.close conn.close
[解决办法]
conn.CursorLocation = adUseClient
[解决办法]
Set conn = New ADODB.Connection Set rs = New ADODB.Recordset conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & App.Path & "\DBEmp.mdb;" & _ "Persist Security Info=False"conn.CursorLocation = adUseClient rs.open"select * from EmpTable",conn,3,3 Set MSHFlexGrid1.DataSource = rs rs.close
[解决办法]
Set conn = New ADODB.Connection Set rs = New ADODB.Recordset Set cmd = New ADODB.Command conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & App.Path & "\DBEmp.mdb;" & _ "Persist Security Info=False" conn.Open cmd.CommandType = adCmdText cmd.ActiveConnection = conn cmd.CommandText = "select * from EmpTable" Set rs = cmd.Execute Set MSHFlexGrid1.DataSource = rs
[解决办法]