Inserting radio buttons values into a database [* resolved *]
Hello,
I have a database with 3 fields High and Low. The datatype in the database using MS Access is 'YesNo'.
I have this code in Visual C#
Code:
OleDbCommand cmdInsert = cnnstrInsert.CreateCommand();
cmdInsert.CommandType = CommandType.Text;
cmdInsert.CommandText = @"INSERT INTO Customer(Customer, High, Low) VALUES('" + txtCustID.Text + "', '" + radHigh.Checked + "', "' + radLow.Checked + "') ";
cmdInsert.ExecuteNonQuery();
There is nothing wrong with the actual syntax, but how do l send the values for the radio buttons to the database.
I keep getting a error msg say "incorrect datatype match". So started to do some testing and used this in the connection string instead.
@"INSERT INTO Customer(Customer, High, Low) VALUES('" + txtCustID.Text + "', 'True', 'False') ";
This still gave the same error.
Can anyone tell me the correct way to insert the values of radio buttons into a database.
Many thanks in advance,
Steve
Re: Inserting radio buttons values into a database [* resolved *]
how do i insert Radio box value into the database. for example, S=Small, M=Medium or L=Large?
Re: Inserting radio buttons values into a database [* resolved *]
Hello,
This is a old post.
I will have to review and get back to you in a few days.
Re: Inserting radio buttons values into a database [* resolved *]
I have figure it out
Code:
if (radSmall.Checked)
{
strRAD = "S";
}
if (radMid.Checked)
{
strRAD = "M";
}
if (radLG.Checked)
{
strRAD = "L";
}
Print 'strRAD' into the database
:wave: