Hi!
There is a little bit think I didnt understand. I should be wrong in my way.
This is my log in interface. When I leave textbox blank he let you inform that textbox are blank, etc...
Then when I introduce the username and password. Even it's correct its bugging on this line of code:
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["mfwamba"].ConnectionString);
After that I do try this:
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["localhost\\sqlexpress\\mfwamba"].ConnectionString);
Even this line of code that's not work.
I put the right that DBconnection. But its does not work. What's happen. Need help please:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
protected void btnSubmit_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["mfwamba"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("select * from UserInformation where UserName =@username and Password=@password",con);
cmd.Parameters.AddWithValue("@username", txtUserName.Text);
cmd.Parameters.AddWithValue("@password", txtPWD.Text);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
if(dt.Rows.Count>0)
{
Response.Redirect("Details.aspx");
}
else
{
ClientScript.RegisterStartupScript(Page.GetType(), "validation", "");
}
}
Sanjeeb LenkaPosted Jul 18, 2013, 5:36 AM
are you able to login with your credential directly in SSMS
Divin MfwambaPosted Jul 18, 2013, 5:31 AM
Then in aspx.cs, I wrote like this:
SqlConnection con = new SqlConnection("Server=localhost\\sqlexpress;Database=mfwamba;User Id=Leader;Password=jisrae;")
Iftikar HussainPosted Jul 17, 2013, 1:14 PM
Please check your web.config file for below config entry
Regards,
Iftikar
Sanjeeb LenkaPosted Jul 17, 2013, 12:11 PM
or you can directly write the connection string and check its working or not.
ex:
SqlConnection con = new SqlConnection("
Server=myServerAddress;Database=myDataBase;User Id=myUsername;");Password=myPassword;