首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

MSHFlexGrid1和ADODB有关问题

2012-01-15 
MSHFlexGrid1和ADODB问题Set conn New ADODB.ConnectionSet rs New ADODB.RecordsetSet cmd New ADO

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行,实际有多行,不知错在哪?

[解决办法]

VB code
    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 '数据源
[解决办法]
VB code
  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

[解决办法]
VB code
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
[解决办法]
VB code
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
[解决办法]
探讨
VB code
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=" &amp; App.Path &amp; "\db1.mdb;Mo……

热点排行