0

So I'm receiving this problem, I tried everything. Kinda stuck

My access database design:

ID - AutoNumber
Data - ShortText

And the insert command:

OleDbCommand command = new OleDbCommand();

string sql = "INSERT INTO Table (Data) VALUES (@Data)";
OleDbCommand cmd = new OleDbCommand(sql, connection);
cmd.Parameters.AddWithValue("@Data", "Test");

connection.Open();

try
{
    cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
    MessageBox.Show("err: " + ex);
    throw;
}

connection.Close();

This might be dumb but I'm really lost and I have no idea what to do.

0

1 Answer 1

3

The TABLE is a reserved keyword so you should change it's name or you should enclose it in square brackets like [Table]:

string sql = "INSERT INTO [Table] (Data) VALUES (@Data)";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.