我想将主页与 ASP 中的用户登录连接起来。我使用 MS SQL 2005 并编写了以下代码,但没有得到任何结果。任何人都可以帮助我了解连接字符串吗?
Dim MyLogin
Set MyLogin = Server.CreateObject("ADODB.Connection")
MyLogin.Open "Provider=MSDASQL;Data Source=10.10.10.10; Initial Catalog=testdb; User Id=123; Password=456;"
SQLtemp = "SELECT * FROM users WHERE UserName = '" & Request.Form("username") & "' AND Password = '" & Request.Form("password") & "'"
Set rs = MyLogin.Execute(SQLtemp)
while not rs.eof
If Request.Form("username") = rs("UserName") AND Request.Form("password") = rs("Password") Then
dim Your_UserName
Your_UserName = rs("UserName")
dim Date_In
Date_In = rs("Entry_Date")
Response.Cookies("UserName") = Your_UserName
Response.Cookies("still") = Date_In
Session.TimeOut = 20
Session("UserName") = "Yes"
Response.Redirect "protected.asp?UserLoggedIn=" & Your_UserName
Else
Session("Message") = ("<font face=""Verdana"" size=""2"" color=""#FF0000"">Login Failed! </font><font face=""Verdana"" size=""2"" color=""#0000FF"">Incorrect Username & Password.</font>")
Response.Redirect ("login.asp")
Response.End
End If
rs.MoveNext
Wend
OnError Response.Redirect ("login.asp")
rs.Close
MyLogin.Close
set MyLogin = Nothing
%>