Here is my check login function:
protected bool checkLoginStatus(String email, String password)
{
bool loginStatus = false;
bool status = false;
try
{
Connector.openConn();
String str = "SELECT * FROM [User]";
SqlCommand cmd = new SqlCommand(str, Connector.conn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "tblUser");
//check valid
foreach (DataRow dr in ds.Tables[0].Rows)
{
if (email == dr["Email"].ToString()
&& password == Connector.base64Decode(dr["Password"].ToString()))
{
Session["login_status"] = true;
Session["username"] = dr["Name"].ToString();
Session["userId"] = dr["UserId"].ToString();
status = true;
break;
}
}
}
catch (Exception ex)
{ }
finally {
Connector.closeConn();
}
return status;
}
And call it at my aspx page:
String email = Login1.UserName.Trim();
String password = Login1.Password.Trim();
if (checkLoginStatus(email, password))
Response.Redirect(homeSite);
else
lblFailure.Text = "Invalid!";
I ran this page at localhost successful!
When I published it to server, this function only can run if email and password correct! Other, error occured:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
I tried open SQL Server 2008 Configuration Manager and enable SQL Server Browser service (Logon as:NT Authority/Local Service) but it stills error.
(note: here is connection string of openConn() at Localhost (run on SQLEXpress 2005)
connectionString="Data Source=MYLAPTOP\SQLEXPRESS;Initial Catalog=Spider_Vcms;Integrated Security=True" />
)
At server (run on SQL Server Enterprise 2008)
connectionString="Data Source=SVR;Initial Catalog=Spider_Vcms;User Id=abc;password=123456;" />
anyone have an answer for my problem :(
thanks a lot!