Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Syntax Error on INSERT INTO statement

Author  Topic 

lsutiger
Starting Member

1 Post

Posted - 2009-11-04 : 12:57:31
Hi all!
I am a bit rusty at SQL. I am receiving a Sytax Error on an INSERT INTO statement. I am using C# in the VS2003 IDE and trying to pass parameters. Here is the statement copied directly from the debugger:
INSERT INTO bonus-sales-rpt [STORE-NUM], [MODEL], [SERIAL], [COST], [INCOME], [DATESOLD], [STATUS] VALUES (@SN, @MDL, @SRL, @CST, @INC, @DS, @STA)


Here is the code in C#:

command1.CommandText = "INSERT INTO bonus-sales-rpt [STORE-NUM], [MODEL], [SERIAL], [COST], [INCOME], [DATESOLD], [STATUS] " +
"VALUES (@SN, @MDL, @SRL, @CST, @INC, @DS, @STA)" ;
command1.Parameters.Add("@SN",OleDbType.VarChar); //text in access
command1.Parameters.Add("@MDL",OleDbType.VarChar);//text iu access
command1.Parameters.Add("@SRL",OleDbType.VarChar);//text in access
command1.Parameters.Add("@CST",OleDbType.Decimal);//number(decimal 8.2) in access
command1.Parameters.Add("@INC",OleDbType.Decimal);//number(decimal 8.2) in access
command1.Parameters.Add("@DS",OleDbType.DBDate);//date in access
command1.Parameters.Add("@STA",OleDbType.VarChar);//text in access


command1.Parameters["@SN"].Value = DbReader["INV-LOCATION-REC-1"].ToString();
command1.Parameters["@MDL"].Value = DbReader["INV-MK-MODEL-NBR"].ToString();
command1.Parameters["@SRL"].Value = DbReader["INV-MK-SERIAL-NBR"].ToString();
command1.Parameters["@CST"].Value = Decimal.Parse(DbReader["INV-ORIGINAL-COST"].ToString());
command1.Parameters["@INC"].Value = Decimal.Parse(DbReader["INV-RENTAL-REVENUE"].ToString());
command1.Parameters["@DS"].Value = DbReader["INV-DATE-SOLD"];
command1.Parameters["@STA"].Value = DbReader["INV-STATUS"].ToString();
try
{
conn.Open();
command1.ExecuteNonQuery();
conn.Close();
}




Do you see the problem with the INSERT INTO statement?

Thanx in advance!

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-11-04 : 13:02:26
you're missing parentheses:

INSERT INTO bonus-sales-rpt ([STORE-NUM], [MODEL], [SERIAL], [COST], [INCOME], [DATESOLD], [STATUS])
Go to Top of Page
   

- Advertisement -