Private Sub SystemInit()
Dim Rs As Recordset
Dim conStr As String
Dim cnDB As Connection
Set cnDB = New Connection
conStr = "Provider=SQLOLEDB.1;User ID=sa;Password=;" & _
"DataSource=(local);Database=baizi;Persist Security Info=False"
cnDB.ConnectionString = conStr
cnDB.Open
If cnDB = True Then //说这句话类型不匹配
Set Rs = New Recordset
Rs.CursorLocation = adUseClient
If Rs.State <> adStateClosed Then Rs.Close
Rs.Open "Select Name,Password from Users", cnDB, adOpenForwardOnly, adLockReadOnly
If Rs.RecordCount = 0 Then
bNoUser = True
MsgBox "请先建立一个系统管理用户" & Space(5), vbInformation + vbOKOnly, "系统提示"
frmAddUser.Show
Else
bNoUser = False
Me.Show
Exit Sub
End If
Rs.Close
Set Rs = Nothing
Unload Me
Else
MsgBox "数据库连接失败,请重新启动程序" & Space(5), vbExclamation + vbOKOnly, "启动失败" '数据库连接失败则退出程序
Unload Me
End If
End Sub