Dim dbAdo As New ADODB.Connection Dim recRs As New ADODB.Recordset Dim strSql As String Dim strCon As String strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\db1.mdb;Persist Security Info=False" dbAdo.CursorLocation = adUseClient dbAdo.CommandTimeout = 15 dbAdo.ConnectionString = strCon dbAdo.Open strSql = "Select * From 表1" recRs.Open strSql, dbAdo, adOpenDynamic, adLockReadOnly If recRs.RecordCount > 0 Then MSHFlexGrid1.Rows = 2 '需要加列标题程序 Else Set MSHFlexGrid1.DataSource = recRs End If
这个问题我也遇到过,把mshflxgrid clear一下,重新写入数据应该没问题了
to lisong770818(懒人) ( ) ,这样没用。 cuizm(射天狼)的可以。但总觉得这样自己添加,很繁。
对不起,我程序中有一句写错了,就是if语句中>改成=,望见谅! Dim dbAdo As New ADODB.Connection Dim recRs As New ADODB.Recordset Dim strSql As String Dim strCon As String strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\db1.mdb;Persist Security Info=False" dbAdo.CursorLocation = adUseClient dbAdo.CommandTimeout = 15 dbAdo.ConnectionString = strCon dbAdo.Open
strSql = "Select * From 表1" recRs.Open strSql, dbAdo, adOpenDynamic, adLockReadOnly If recRs.RecordCount = 0 Then MSHFlexGrid1.Rows = 2 '需要加列标题程序 Else Set MSHFlexGrid1.DataSource = recRs End If
在set mshflexgrid1.datasource=rs
Dim recRs As New ADODB.Recordset
Dim strSql As String
Dim strCon As String strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\db1.mdb;Persist Security Info=False"
dbAdo.CursorLocation = adUseClient
dbAdo.CommandTimeout = 15
dbAdo.ConnectionString = strCon
dbAdo.Open
strSql = "Select * From 表1"
recRs.Open strSql, dbAdo, adOpenDynamic, adLockReadOnly
If recRs.RecordCount > 0 Then
MSHFlexGrid1.Rows = 2
'需要加列标题程序
Else
Set MSHFlexGrid1.DataSource = recRs
End If
Dim dbAdo As New ADODB.Connection
Dim recRs As New ADODB.Recordset
Dim strSql As String
Dim strCon As String strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\db1.mdb;Persist Security Info=False"
dbAdo.CursorLocation = adUseClient
dbAdo.CommandTimeout = 15
dbAdo.ConnectionString = strCon
dbAdo.Open
strSql = "Select * From 表1"
recRs.Open strSql, dbAdo, adOpenDynamic, adLockReadOnly
If recRs.RecordCount = 0 Then
MSHFlexGrid1.Rows = 2
'需要加列标题程序
Else
Set MSHFlexGrid1.DataSource = recRs
End If