Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have this code on button to login and open main form

KorisnikLozinkaString is sql built on dataset and it works fine there.
datasource is accdb database which has usernames and passwords


Korisnik is username
Lozinka is password

C#
private void button1_Click(object sender, EventArgs e)

dynamic login = this.usersTableAdapter2.KorisnikLozinkaString(textBox1.Text, textBox2.Text);

{
if (login == null)
MessageBox.Show("Wrong Entry");
}

???????


and I don't know how to make it to work, I need the if or else statement that will open allow logging in and opening main form.

help
Posted
Updated 18-Feb-11 5:27am
v4

It's hard to know what you are doing without seeing what the KorisnikLozinkaString method does.
 
Share this answer
 
Comments
shonezi 18-Feb-11 11:41am    
SELECT COUNT(*) AS Result, Korisnik AS KorisnikInput, Lozinka AS LozinkaInput
FROM users
GROUP BY Korisnik, Lozinka
HAVING (COUNT(*) = 1) AND (Korisnik = ?) AND (Lozinka = ?)
Nish Nishant 18-Feb-11 11:45am    
Can you show the designer generated method though? This is the SQL, I am looking for the C# code.
Nish Nishant 18-Feb-11 11:56am    
Can you right click on KorisnikLozinkaString and select go to definition? That will take you to the method directly. And then you can copy/paste just that method.
shonezi 18-Feb-11 11:48am    
this is form called Login with two textboxes and button, I have another form which I want to to open when typing in proper username and password click on button to open. I am new to C# and visual studio.

namespace ATM
{
public partial class Login : Form
{
public Login()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{

dynamic login = this.usersTableAdapter2.KorisnikLozinkaString(textBox1.Text, textBox2.Text);

{
if (login == null)
MessageBox.Show("Wrong entry");

}

}


}
}
Nish Nishant 18-Feb-11 11:51am    
The designer generates code for you. It will be a file named xxx.designer.cs (where xxx is your class name). Can you copy/paste the method here?
I found a solution, easy one, right in front of my eyes:

private void button1_Click(object sender, EventArgs e)
{
dynamic login = this.usersTableAdapter2.KorisnikLozinkaString(textBox1.Text, textBox2.Text);
if (login == null)
{
MessageBox.Show("Wrong entry");
}
else
{
MessageBox.Show(Succesfull login");
mainForm main = new MainForm();
main.Show();
this.Hide();
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900