I have been coding error it is not connecting to my mysql database
Is shows error:
'Basic.exe' (CoreCLR: DefaultDomain): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.3\System.Private.CoreLib.dll'. Skipped loading symbols.
The module is optimized and the debugger option 'Just My Code' is enabled.
The thread 0x23ec has exited with code 0 (0x0). The thread 0x35bc has exited with code 0 (0x0). The thread 0x3b6c has exited with code 0 (0x0).
The thread 0x1274 has exited with code 0 (0x0).
The program '[10052] Basic.exe' has exited with code 0 (0x0).
private void button6_Click(object sender, EventArgs e)
{
SqlConnection con -new SqlConnection("Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Administrator\source\MySQL\testDB.mdf;Integrated Security=True;Connect Timeout=30");
con.Open();
SqlCommand cmd = new SqlCommand("insert into testDb.employee values (@employee_id,@employee_name,@employee_salary)", con);
cmd.Parameters.AddWithValue("@employee_id", int.Parse(textBox6.Text));
cmd.Parameters.AddWithValue("@employee_name", textBox7.Text);
cmd.Parameters.AddWithValue("@employee_salary", int.Parse(textBox8.Text));
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Successfully Record Saved");
}
My SQL Database:
SELECT FROM testdb.employee;
insert into testDB.employee(employee_id,employee_name,employee_salary) Values ('123','RAFI','10000')
insert into testDB.employee(employee_id,employee_name,employee_salary) Values ('456','RAJESH','20000')
insert into testDB.employee(employee_id,employee_name,employee_salary) Values ('789','RAMESH','30000')
select from testDB.employee
emp_id employee_name employee_salary
123 RAFI 10000
456 RAJESH 20000
789 RAMESH 30000