0
我想在ASP中將主頁與用戶登錄連接起來。我使用MS SQL 2005,我編寫了下面的代碼,但我沒有得到任何結果。任何人都可以幫助我瞭解連接關係嗎?SQL Server 2005與ASP經典連接
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
%>
任何人都可以幫助我嗎? –