0

我想将主页与 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

%>
4

1 回答 1

1

试试这些。

Provider=SQLOLEDB;Data Source=127.0.0.1;Initial Catalog=dbname;User Id=youruid;Password=yourpwd

Provider=SQLNCLI;Server=127.0.0.1;Database=dbname;Uid=youruid;Pwd=yourpwd

你的数据库是快递版吗?如果是需要在数据源IP后面加上\SQLEXPRESS

于 2013-05-17T12:09:36.027 回答