新手上路,想跟数据库连接,进行密码登陆,下是确定按件的代码,其中comdstr,comd,sqlcommand,objconn,sqldatareader都说未定义,是什么没加还是怎么回事,望指教
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim username, userpassword As String
If Page.IsValid Then
username = txtname.Text
userpassword = txtpass.Text
comdstr = "select * from users where (username='" & username & "') and (userpassword='" & userpassword & "')"
comd = New sqlcommand(comdstr.objconn)
objconn.open()
Dim prord As sqldatareader
prord = comd.executereader
If Not prord.read() Then
Response.Write("<script language='jacascript'>alert('输入的用户名或密码错误');history.go(-1);</script>")
Else
Response.Redirect("host.aspx")
End If
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim username, userpassword As String
If Page.IsValid Then
username = txtname.Text
userpassword = txtpass.Text
comdstr = "select * from users where (username='" & username & "') and (userpassword='" & userpassword & "')"
comd = New sqlcommand(comdstr.objconn)
objconn.open()
Dim prord As sqldatareader
prord = comd.executereader
If Not prord.read() Then
Response.Write("<script language='jacascript'>alert('输入的用户名或密码错误');history.go(-1);</script>")
Else
Response.Redirect("host.aspx")
End If
End If
End Sub
imports system.data
imports system.data.sqlclient