首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

请大家帮小弟我看看这个代码哪里有有关问题!(急)

2012-03-25 
请大家帮我看看这个代码哪里有问题!(急)Private Sub CommandButton1_Click()Dim cn As ObjectDim rs As Ob

请大家帮我看看这个代码哪里有问题!(急)
Private Sub CommandButton1_Click()
Dim cn As Object
Dim rs As Object
Dim j As String
Dim h As String
Dim strSQL As String
j = TextBox1.Value
h = TextBox2.Value
Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=;Data Source=c:\test\date.mdb"
strSQL = "select * from user where user_name='" & j & "' and pwd='" & h & "'"
rs.Open strSQL, cn, 1, 1
If Not rs.EOF Then
MsgBox ("歡迎登陸本系統")
End If
rs.Close
End Sub
----------------------------
为什么老是说“rs.Open strSQL, cn, 1, 1”这句from子句中有语法错误,请大家帮忙看看,谢了!

[解决办法]

VB code
select * from [user] where user_name='" & j & "' and pwd='" & h & "'
[解决办法]
strSQL = "select * from [user] where [user_name]='" & j & "' and [pwd]='" & h & "'"

[解决办法]
VB code
Select * From [user] Where User_Name='"&TextBox1.Value &"' and pwd='"&TextBox2.Value &"' 

热点排行