Reputation: 182
I can't seem to find my error at my code. I copy-pasted it with another one of my codes and just change the table and column names.
It states the error at : "int result = cma.ExecuteNonQuery();
"
public bool SaveCheckAmount(string id, int amount, string number, string bank)
{
conn.Open();
SqlCeCommand cma = new SqlCeCommand("INSERT INTO Check (transactionID,Amount,CheckNumber,Bank)VALUES(@id,@amount,@number,@bank)",conn);
cma.Parameters.Add("@id",id);
cma.Parameters.Add("@amount",amount);
cma.Parameters.Add("@number",number);
cma.Parameters.Add("@bank",bank);
int result = cma.ExecuteNonQuery();
if(result > 0)
{
conn.Close();
return true;
}
else
{
conn.Close();
return false;
}
}
Upvotes: 1
Views: 195
Reputation: 1620
Check
is a reserved SQL keyword, try this:
INSERT INTO [Check]
Upvotes: 2
Reputation: 29061
Try changing this to
SqlCeCommand cma = new SqlCeCommand("INSERT INTO [Check] (transactionID,Amount,CheckNumber,Bank) VALUES (@id,@amount,@number,@bank)",conn);
Check
is a reserved word in T-SQL.
See this page on MSDN for a complete list.
Upvotes: 3