yes sir need to select any one at a time. and i am using mysql not sql
N Mohamed rafi
Posts
-
Inserting Through Radionbutton and checkbox -
Inserting Through Radionbutton and checkboxMy insert code is not working fine, bcz if i click radionbutton2 and checkbox 2 means it was inserting data automatically radionbutton1 and checkbox1 only, actually if which textbox is selected that data should enter null value radionbutton data should not saved in db if (!string.IsNullOrEmpty(textBox11.Text) && !string.IsNullOrEmpty(textBox12.Text) && !string.IsNullOrEmpty(textBox13.Text) && !string.IsNullOrEmpty(textBox14.Text) && (radioButton1.Checked || radioButton2.Checked) && (checkBox1.Checked || checkBox2.Checked)) { string connectionString; MySqlConnection cnn; connectionString = @"Data Source=localhost;Initial Catalog=testDB;User ID=root;Password=mysql"; cnn = new MySqlConnection(connectionString); cnn.Open(); string id = textBox14.Text; string name = textBox11.Text; string year = textBox12.Text; string quality = radioButton1.Text == "" ? radioButton2.Text : radioButton1.Text; string taste = checkBox1.Text == "" ? checkBox2.Text : checkBox1.Text; string sales = textBox13.Text; textBox11.Text = ""; textBox12.Text = ""; textBox13.Text = ""; textBox14.Text = ""; radioButton1.Text = ""; radioButton2.Text = ""; checkBox1.Text = ""; checkBox2.Text = ""; string query = "INSERT INTO fruits VALUES(@fruitsid, @fruitsname, @fruitsyear, @quality, @taste, @sales)"; using (MySqlCommand cmd = new MySqlCommand(query)) { cmd.Parameters.AddWithValue("@fruitsid", Convert.ToInt32(id)); cmd.Parameters.AddWithValue("@fruitsname", name); cmd.Parameters.AddWithValue("@fruitsyear", year); cmd.Parameters.AddWithValue("@quality", quality); cmd.Parameters.AddWithValue("@taste", taste); cmd.Parameters.AddWithValue("@sales", sales); cmd.Connection = cnn; cmd.ExecuteNonQuery(); MessageBox.Show("Record Inserted Successfully"); DisplayData(); cnn.Close();
-
Password CAPS not Checking in my codePlease provide solution or idea
-
Password CAPS not Checking in my codeok provide solution and article link pls
-
Password CAPS not Checking in my codeI saved my password in CAPS includes but if i enter in small letters its also logged in how to change it?
private void button14_Click(object sender, EventArgs e)
{
if (textBox9.Text != "" && textBox10.Text != "")
{
string connectionString;
MySqlConnection cnn;
connectionString = @"Data Source=localhost;Initial Catalog=testDB;User ID=root;Password=mysql";
cnn = new MySqlConnection(connectionString);
string id = textBox9.Text;
string password = textBox10.Text;
textBox9.Text = "";
textBox10.Text = "";
string query = "select count(*) from login where userid=@userid and password=@password";
using (MySqlCommand cmd = new MySqlCommand(query))
{
cmd.Parameters.AddWithValue("@userid", id);
cmd.Parameters.AddWithValue("@password", password);
cmd.Connection = cnn;
cnn.Open();
cmd.ExecuteNonQuery();
int result = Convert.ToInt32(cmd.ExecuteScalar());
DialogResult dr = MessageBox.Show("Are you sure to Login now?", "Confirmation", MessageBoxButtons.YesNo);
if (dr == DialogResult.Yes && result > 0)
{
MessageBox.Show("Login Successfully");
cnn.Close();
this.Hide();
Form2 f2 = new Form2();
f2.ShowDialog();
}
else
{
MessageBox.Show("Login Failed");
}
}
}
else
{
MessageBox.Show("Please Enter Correct Login details");
}} }
-
Error on CodingError:
the name cmd does not exist in current context
if(textBox9.Text!="" && textBox10.Text!= "")
{
string connectionString;
MySqlConnection cnn;
connectionString = @"Data Source=localhost;Initial Catalog=testDB;User ID=root;Password=mysql";
cnn = new MySqlConnection(connectionString);
string id = textBox9.Text;
string password = textBox10.Text;
textBox9.Text = "";
textBox10.Text = "";
string query = "select count (*) from login where userid='" + textBox9.Text + "' and password='" + textBox10.Text + "'";
int count = Convert.ToInt32(cmd.ExecuteScalar());
using (MySqlCommand cmd = new MySqlCommand(query))
if (count >= 1)
{
cmd.Parameters.AddWithValue("@userid", id);
cmd.Parameters.AddWithValue("@password", password);
cmd.Connection = cnn;
cnn.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("Login Successfully");
cnn.Close();
this.Hide();
Form2 f2 = new Form2();
f2.ShowDialog();
}
else
{
MessageBox.Show("Please Enter Correct Login details");
}} else { MessageBox.Show("Please Enter Details to Login"); }
-
Mysql Query ErrorI have stored userid and password in mysql database, this query is showing login successfully for not stored data, so please correct it
string query = "select * from login where userid=@userid and password=@password";
using (MySqlCommand cmd = new MySqlCommand(query))
{
cmd.Parameters.AddWithValue("@userid", id);
cmd.Parameters.AddWithValue("@password", password);
cmd.Connection = cnn;
cnn.Open();
cmd.ExecuteNonQuery();
DialogResult dr = MessageBox.Show("Are you sure to Login now?", "Confirmation Message", MessageBoxButtons.YesNo);
if (dr == DialogResult.Yes)
{
MessageBox.Show("Login Successfully");
cnn.Close();
this.Hide();
Form2 f2 = new Form2();
f2.ShowDialog(); -
C# to Mysql Login code ErrorWaste of time in this forum. Bye
-
C# to Mysql Login code ErrorSir, Now you give the right code or not?
-
C# to Mysql Login code ErrorPls correct and send me in my code sir that why i can understand sir send me please
-
C# to Mysql Login code ErrorSir, You all are blaming me always, you know the code but you are not providing me. Thank you all.
-
C# to Mysql Login code ErrorSir, How to write mysql query if stored userid password is correct means then it enter successfull suppose not stored values entered means the messagebox is wrong.....
-
C# to Mysql Login code ErrorWhy you are not correcting my code and sending me? i said the error you know the code and sending some examples also then you can send correct code it is useful to me please
-
C# to Mysql Login code ErrorI have changed my code sir, but still logging in for wrong userid and password
if (textBox9.Text != "" && textBox10.Text != "")
{
string connectionString;
MySqlConnection cnn;
connectionString = @"Data Source=localhost;Initial Catalog=testDB;User ID=root;Password=mysql";
cnn = new MySqlConnection(connectionString);
string id = textBox9.Text;
string password = textBox10.Text;
textBox9.Text = "";
textBox10.Text = "";
string query = "select * from login where userid=@userid and password=@password";
using (MySqlCommand cmd = new MySqlCommand(query))
{
cmd.Parameters.AddWithValue("@userid", id);
cmd.Parameters.AddWithValue("@password", password);
cmd.Connection = cnn;
cnn.Open();
cmd.ExecuteNonQuery();
DialogResult dr = MessageBox.Show("Are you sure to Login now?", "Confirmation Message", MessageBoxButtons.YesNo);
if (dr == DialogResult.Yes)
{
MessageBox.Show("Login Successfully");
cnn.Close();
this.Hide();
Form2 f2 = new Form2();
f2.ShowDialog();
}
else if (dr == DialogResult.No)
{
MessageBox.Show("Please Enter Correct Login details");
}
}
}
else
{
MessageBox.Show("Please Enter With Correct Login Details");
} -
C# to Mysql Login code ErrorPut the same code in my code that why i can understand easily sir
-
C# to Mysql Login code ErrorHow to change code in my coding like this sir? because my code is logging in if i enter wrong username and password also
-
C# to Mysql Login code ErrorI clearly telling again mysql query is error here, ExecuteNonQuery is returned value it means i logged in with wrong userid and password also.
-
C# to Mysql Login code ErrorSir, I pay attention sir, you said i am passing 2parameters now i am passing 3parameters and login means it shows login successful with wrong userid password also i think my sql query should be change here
-
C# to Mysql Login code ErrorSir, I have passed 3parameters but still it login in with wrong user id password also, how to write correct mysql query here?
string connectionString;
MySqlConnection cnn;
connectionString = @"Data Source=localhost;Initial Catalog=testDB;User ID=root;Password=mysql";
cnn = new MySqlConnection(connectionString);
//cnn.Open();
string id = textBox9.Text;
string password = textBox10.Text;
string loginid = "";
textBox9.Text = "";
textBox10.Text = "";
string query = "select * from login where userid=@userid and password=@password and loginid=@loginid";
using (MySqlCommand cmd = new MySqlCommand(query))
{
cmd.Parameters.AddWithValue("@userid", id);
//cmd.Parameters.AddWithValue("@employee_id", Convert.ToInt32(id));
cmd.Parameters.AddWithValue("@password", password);
cmd.Parameters.AddWithValue("@loginid", loginid);
//cmd.Parameters.AddWithValue("@confirmpassword", confirmpassword);
cmd.Connection = cnn;
cnn.Open();
cmd.ExecuteNonQuery();
DialogResult dr = MessageBox.Show("Are you sure to Login now?", "Confirmation", MessageBoxButtons.YesNo);
if (dr == DialogResult.Yes)
{
MessageBox.Show("Login Successfully");
cnn.Close();
this.Hide();
Form2 f2 = new Form2();
f2.ShowDialog();
}
else if (dr == DialogResult.No)
{
MessageBox.Show("Please Enter Correct Login details");
}
}
}
else
{
MessageBox.Show("Please Enter details to Login");
}
} -
C# to Mysql Login code ErrorSir, how to save password securely? pls suggest in my code and mysql query also wrong bcz it login with wrong userid and password also