I'm currently trying to solve a error which I encountered in my C# program.
I want to insert into my Access database the name I type into my nameTextBox after I click the 'ADD' button.
This is the code in my addButton_Click.
private void addNameButton_Click(object sender, EventArgs e)
{
OleDbConnection myCon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=K:\\stopwatchApp\\time.mdb");
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = myCon;
//cmd.CommandType = CommandType.Text;
cmd.CommandText = "INSERT into Table1 (TeamName) Values('"+inputNameTextBox.Text+"')";
//cmd.Connection = myCon;
myCon.Open();
cmd.ExecuteNonQuery();
myCon.Close();
MessageBox.Show("Record updated!");
}
This is the error I encountered:
The INSERT INTO statement contains the following unknown field name: 'TeamName'. Make sure you have typed the name correctly, and try the operation again.
Attached is my GUI.
Regards,
Demi C.

New Topic/Question
Reply



MultiQuote





|