我的程序能运行,可是就是数据没在MSFlexGrid控件中显示出来
Dim cnDB As Connection
Dim Rs As Recordset
Dim conString As String
Private Sub Command1_Click()
On Error Resume Next
If MsgBox("数据删除后将不能恢复,确认要删除当前数据么?", vbQuestion + vbYesNo, "删除数据") = vbNo Then
Exit Sub
Set cnDB = New Connection
conString = "Provider=SQLOLEDB.1;User ID=sa;Password=;" & _
"DataSource=(local);Database=baizi;Persist Security Info=False"
cnDB.ConnectionString = conString
Set Rs = New Recordset
conString = "select * from bm where name='" & txtbm & "'"
If querydata(conString) = False Then Exit Sub
Rs.MoveFirst
Rs.Delete
If Rs.EOF Then
Rs.MoveFirst
Else
Rs.MoveNext
End If
Call shuaxin
txtbm.Text = ""
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Call shuaxin
End Sub
Private Sub shuaxin()
Dim chaxun As String
If chaxun = Empty Then
chaxun = "Select * from bm"
End If
If querydata(chaxun) = True Then
End If
msfxinxi.Rows = 1
msfxinxi.Cols = 2
msfxinxi.Row = 0
msfxinxi.Col = 0
msfxinxi.Text = "部门名"
msfxinxi.ColWidth(0) = 800
msfxinxi.CellAlignment = felAlignCenterCenter
On Error Resume Next
Rs.MoveFirst
If Err.Number > 0 Then Exit Sub
Do While Not Rs.EOF
msfxinxi.AddItem (Empty)
msfxinxi.Row = msfxinxi.Rows - 1
msfxinxi.Col = 0
msfxinxi.Text = Rs.fields("name").Value
Loop
End Sub
Public Function querydata(ByVal strsql As String) As Boolean
On Error Resume Next
Set rct = New ADODB.Recordset
Call rct.Open(strsql, con, adOpenDynamic, adLockOptimistic, -1)
If Err.Number > 0 Then
Err.Clear
querydata = False
Else
querydata = True
End If
End Function