VB连接SQL数据库问题

来源:百度知道 编辑:UC知道 时间:2024/07/07 13:11:04
Public db As ADODB.Connection '使用ADO对象连接到ODBC数据源
Public CurrentTable As String '记录当前表格
Public UID As String '登录用户名称
Public PWD As String '用户登录密码
Public ReportTitle As String '销售报表的标题
Public ReportDays As Integer '要制作多少天的销售报表
以上是模块中的部分代码。
Private Sub cmdLogin_Click()
'On Error Resume Next
UID = txtUserName.Text
PWD = txtPassword.Text
'txd = cobServer
If db.ConnectionString <> "" Then
MsgBox "请先注销再登录!", , "登录"
Unload Me
Exit Sub
End If
db.ConnectionString = "Provider=SQLOLEDB.1;" & _
"Persist Security Info=false;" & _
"User ID=" & UID & _
";Password=" & PWD & _
";Initial Catalog=jxcdatabase;" & _
"Data Source=(local)"
db.Open
'使各菜单有效,因为已有用户登录
With frmMain
!mnuTrade.Enabled = True

在连接语句中加入 Integrated Security=SSPI;
使用windows自身验证。

在主文件上C:\Program Files\LuoSoft\奇迹英语智能记忆\luoSoft.exe弹右键时选“属性”——“兼容性”,在“特权等级”——“请以管理员身份运行该程序”前划勾。确定保存就OK了。