I need to get the userid(primary key auto_increment) from another table(login) into userdetails table. When trying to run it I keep getting this error " incorrect integer value: 'LAST_INSERT_ID()' for column 'userid' at row 1".
I've tried to take LAST_INSERT_ID() out and run another query after query4 to insert the value into the userid but I can't get it to insert into the right row it just opens a new row.
this is the code am trying to run.
try
{
    //This is my connection string i have assigned the database file address path  
    string MyConnection2 = "datasource=localhost;port=3310;database=e-votingsystem;username=root;password=Password12;";
    //this is my insert query in which i am taking input from the user through windows forms                
    string Query2 = "INSERT INTO vote (username) VALUE ('" + usernameInputBox.Text + "');";
    string Query3 = "INSERT INTO login (username,upassword) VALUE ('" + usernameInputBox.Text + "','" + passwordInputBox.Text + "');";
    string Query4 = "INSERT INTO userdetails (nationalinsurance,userid,forename,middlename,surname,housenumber,street,towncity,postcode,suffix) VALUES ('" + nationalInsuranceInputBox.Text + "','"+"LAST_INSERT_ID()"+"','" + forenameInputBox.Text + "','" + middleNameInputBox.Text + "','" + surnameInputBox.Text + "','" + houseNumberInputBox.Text + "','" + streetTextBox.Text + "','" + towncityTextBox.Text + "','" + postcodeInputBox.Text + "','" + suffixComboBox.Text+"');";                    
    //This is  MySqlConnection here i have created the object and pass my connection string.  
    MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
    //This is command class which will handle the query and connection object.  
    MySqlCommand MyCommand2 = new MySqlCommand(Query2, MyConn2);
    MySqlCommand MyCommand3 = new MySqlCommand(Query3, MyConn2);                    
    MySqlCommand MyCommand4 = new MySqlCommand(Query4, MyConn2);
    MySqlDataReader MyReader2;
    MySqlDataReader MyReader3;                    
    MySqlDataReader MyReader4;
    // opens new connection to database then executes command
    MyConn2.Open();
    MyReader2 = MyCommand2.ExecuteReader();    // Here the query will be executed and data saved into the database.                    
    while (MyReader2.Read())
    {
    }
    MyConn2.Close();
    // opens new connection to database then executes command
    MyConn2.Open();
    MyReader3 = MyCommand3.ExecuteReader();
    while (MyReader3.Read())
    {
    }
    MyConn2.Close();                 
    //opens new connection to database the exexcutes command
    MyConn2.Open();
    MyReader4 = MyCommand4.ExecuteReader();
    while (MyReader4.Read())
    {
    }
    MyConn2.Close();
}
catch(Exception ex)
{
    MessageBox.Show(ex.Message);
}
MessageBox.Show("Hello " + forename + surname, "read and accept the terms and conditions to continue");
//new termsAndConditionsPage().Show();
//Hide();
}
 
     
     
     
     
     
    