arpitroys80

The following code is giving no build errors but error in desired output. The line in RED not executing. And hence evrytime i am getting into the 'else' loop.


private void button_Login_Click(object sender, EventArgs e)
{
Data_entry Next = new Data_entry();
string source = "server = (local); database = test; user id =Arpit; password =aaa";
SqlConnection con1 = new SqlConnection(source);
SqlDataAdapter adp1 = new SqlDataAdapter("select * from Login where username='" + textBox_Username + "' and pwd ='" + textBox_Pwd + "'", con1);
DataSet ds1 = new DataSet();

adp1.Fill(ds1, "Login_details");
int i = adp1.Fill(ds1, "Login_details"); // Whether this line working

if (i > 0)
{
Hide();
Next.Show(); // loads the form Data_entry
}
else
{
string message = "Wrong Username or Password ";
string caption = "Error !!";
DialogResult result;
// Display the MessageBox.
result = MessageBox.Show(message, caption, 0);
}
}

Looking fwd to any suggestions


Re: Windows Forms Data Controls and Databinding Forms Based Login - Plz can anybody tell whats wrong in this code?

Ken Tucker

Code Snippet

int i = adp1.Fill(ds1, "Login_details");

This line of code should return the number of records returned. What are you getting as a return value






Re: Windows Forms Data Controls and Databinding Forms Based Login - Plz can anybody tell whats wrong in this code?

arpitroys80

i am getting 0 (zero) value. But 5 records exist in the table.