Click here to Skip to main content
15,888,330 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this is my code
using (mcon = new MySqlConnection(conString))
            {
                try
                {
                    //insert student data into database
                    string query1 = "INSERT INTO Login_System_DB.Student_tbl(BARCODE,FNAME,LNAME,COURSE,SEX) VALUES(@BAARCODE,@FNAME,@LNAME,@COURSE,@SEX)";
                    mcmd = new MySqlCommand(query1, mcon);

                    //PARAMETERS
                    mcmd.Parameters.Add("@barcode", MySqlDbType.VarChar, 25);
                    mcmd.Parameters.Add("@fname", MySqlDbType.VarChar, 25);
                    mcmd.Parameters.Add("@lname", MySqlDbType.VarChar, 25);
                    mcmd.Parameters.Add("@course", MySqlDbType.VarChar, 25);
                    mcmd.Parameters.Add("@SEX", MySqlDbType.VarChar, 25);

                    //VALUES
                    mcmd.Parameters["@barcode"].Value = txtBARCODE.Text;
                    mcmd.Parameters["@fname"].Value = txtStudentFNAME.Text;
                    mcmd.Parameters["@lname"].Value = txtStudentLNAME.Text;
                    mcmd.Parameters["@course"].Value = txtCOURSE.Text;
                    mcmd.Parameters["@sex"].Value = (rbStudentMALE.Checked == true) ? "MALE" : "FEMALE";

                    mcon.Open();
                    int RowsAffected = mcmd.ExecuteNonQuery();
                    if(RowsAffected > 0)
                    {
                        Console.WriteLine("Student Data: Inserted Successfully");
                    }
                    else
                    {
                        Console.WriteLine("Student Data: Insertion Failed");
                    }

                    mcmd.Dispose();

                    //-------------------------------------------------------------------------------------

                    string query2 = "INSERT INTO Login_System_DB.Guardian_tbl(FNAME,LNAME,RELATIONSHIP,CONTACTNO,SEX) VALUES(@FNAME,@LNAME,@RELATIONSHIP,@CONTACTNO,@SEX)";
                    mcmd = new MySqlCommand(query2, mcon);

                    //PARAMETERS
                    mcmd.Parameters.Add("@FNAME", MySqlDbType.VarChar, 25);
                    mcmd.Parameters.Add("@LNAME", MySqlDbType.VarChar, 25);
                    mcmd.Parameters.Add("@RELATIONSHIP", MySqlDbType.VarChar, 25);
                    mcmd.Parameters.Add("@CONTACTNO", MySqlDbType.VarChar, 25);
                    mcmd.Parameters.Add("@SEX", MySqlDbType.VarChar, 25);

                    //VALUES
                    mcmd.Parameters["@FNAME"].Value = txtGuardianFNAME.Text;
                    mcmd.Parameters["@LNAME"].Value = txtGuardianLNAME.Text;
                    mcmd.Parameters["@RELATIONSHIP"].Value = txtRELATIONSHIP.Text;
                    mcmd.Parameters["@CONTACTNO"].Value = txtCONTACTNO.Text;
                    mcmd.Parameters["@SEX"].Value = (rbGuardianMALE.Checked == true) ? "TRUE" : "FALSE";

                    RowsAffected = mcmd.ExecuteNonQuery();
                    if(RowsAffected > 0)
                    {
                        Console.WriteLine("Guardian Data: Inserted successfully");
                    }
                    else
                    {
                        Console.WriteLine("Guardian Data: Insertion Failed");
                    }
                    mcmd.Dispose();
                }
                catch(Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                finally
                {
                    mcon.Close();
                }
            }


What I have tried:

already tried debugging it by adding break points but no luck... the error it returns also provide insufficient information... pls help.... ^_^
Posted
Updated 20-Mar-17 9:44am
Comments
[no name] 20-Mar-17 15:44pm    
So.... do you think that everyone else on the planet has access to your database? What is it that you would expect to be able to do for you without access to your database, your code, your computer screen to see what the error is, etc, etc, etc? If you are unable to debug your code, how do you expect us to?

1 solution

Found my solution, BAARCODE > BARCODE thanks to me...
 
Share this answer
 
Comments
Patrice T 20-Mar-17 16:57pm    
Accept your answer to close the question.

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