SQL 打开数据库为什么总是提示错误?急死我也,快帮忙

cpf_cn 2001-09-17 09:03:41
Private Sub savemm()
Dim X1, m, a, sql11, b

cn.Close
Set cn = Nothing
Set cn = New ADODB.Connection
cn.Open "Driver={SQL Server};Server=" & s1 & ";Uid=" & "sa" & ";Pwd=" & "" & ";Database=" & "master" & ""
MS1.Row = 1
Do While MS1.Row <= MS1.Rows - 1
MS1.Col = 0: m = MS1.Text: X1 = MS1.Row
MS1.Row = 1
Do While MS1.Row < MS1.Rows - 1
b = MS1.Text
If MS1.Text = "" Then Exit Do
If MS1.Row <> X1 Then
MS1.Col = 1
a = MS1.Text
MS1.Col = 2
If a <> MS1.Text Then MsgBox b & "密码不一致!", vbInformation, "保存用户提示": GoTo errb
If MS1.Text = m Then MsgBox "项目名称" & m & "重复,请重新输入", vbInformation, "保存表格": MS1.CellBackColor = &HFF&: GoTo errb
End If
MS1.Row = MS1.Row + 1
Loop
MS1.Row = X1
If MS1.Text = "" Then Exit Do
sql11 = "select * beeuser where yh='" & MS1.Text & "'and db='" & Trim(restring("system", "curdb")) & "'"
Set rs = New ADODB.Recordset
rs.Open sql11, cn, adOpenKeyset, adLockOptimistic
If rs.RecordCount <= 0 Then
rs.AddNew
Else
rs.Requery
End If
MS1.Col = 0
rs("yh") = MS1.Text
MS1.Col = 1: If MS1.Text <> "" Then rs("mm") = MS1.Text
rs.Update
If MS1.Row = MS1.Rows - 1 Then Exit Do
MS1.Row = MS1.Row + 1
Loop
Set cn = New ADODB.Connection
cn.Open "Driver={SQL Server};Server=" & s1 & ";Uid=" & "sa" & ";Pwd=" & "" & ";Database=" & s2

errb:
Set cn = New ADODB.Connection
cn.Open "Driver={SQL Server};Server=" & s1 & ";Uid=" & "sa" & ";Pwd=" & "" & ";Database=" & s2
End Sub
出现这么多CN是因为我打开了两个数据库
但一运行到RS.OPEN就出错提示:"错误号-2147217900[MICROSOFT][ODBC SQL SERVER DRIVER][SQLSERVER]LINE 1:INCORRECT SYNTAX NEAR 'BEEUSER'.
我前边也出现国类似情况多运行几次就没有了,不知错误在那里,
请多指教
...全文
46 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
cpf_cn 2001-09-17
哦,我漏掉了,原先有,那样也不行
回复
lpf 2001-09-17
好像是
sql11 = select * FROM beeuser where yh='" & MS1.Text & "'and db='" & Trim(restring("system", "curdb")) & "'"
回复
wqb 2001-09-17
sql11 = select * beeuser where yh='" & MS1.Text & "'and db='" & Trim(restring("system", "curdb")) & "
改为:
sql11 = select * FROM beeuser where yh='" & MS1.Text & "'and db='" & Trim(restring("system", "curdb")) & "
回复
相关推荐
发帖

1187

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
帖子事件
创建了帖子
2001-09-17 09:03
社区公告
暂无公告