Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Insert statement syntax error
Message
From
22/04/2009 14:02:52
 
 
To
22/04/2009 13:53:58
General information
Forum:
ASP.NET
Category:
ADO.NET
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Jet/Access Engine
Application:
Desktop
Miscellaneous
Thread ID:
01395927
Message ID:
01395944
Views:
51
This is the statement that CommandBuilder created
CommandText "INSERT INTO tblData (Ave_Nitrate_Level, Ave_PerChlorate_Level, Well_1_Daily_Runtime, Well_2_Daily_Runtime, Well_5_Daily_Runtime, Well_6_Daily_Runtime, CIC_Conn_Daily_Runtime, R1_B1_Daily_Runtime, R1_B2_Daily_Runtime, R1_B3_Daily_Runtime, R2_B1_Daily_Runtime, R2_B2_Daily_Runtime, R3_B1_Daily_Runtime, R3_B2_Daily_Runtime, R3_B3_Daily_Runtime, R4_B1_Daily_Runtime, R4_B2_Daily_Runtime, R9_B1_Daily_Runtime, R9_B2_Daily_Runtime, B7_Daily_Runtime, Well_1_Daily_Starts, Well_2_Daily_Starts, Well_5_Daily_Starts, Well_6_Daily_Starts, R1_B1_Daily_Starts, R1_B2_Daily_Starts, R1_B3_Daily_Starts, R2_B1_Daily_Starts, R2_B2_Daily_Starts, R3_B1_Daily_Starts, R3_B2_Daily_Starts, R3_B3_Daily_Starts, R4_B1_Daily_Starts, R4_B2_Daily_Starts, R9_B1_Daily_Starts, R9_B2_Daily_Starts, B7_Daily_Starts, Well_1_Daily_Flow, Well_2_Daily_Flow, Well_5_Daily_Flow, Well_6_Daily_Flow, CIC_Conn_Daily_Flow, CIC_Blnd_Daily_Flow, R1_Daily_Flow, R2_Daily_Flow, R3_Daily_Flow, R4_Daily_Flow, R9_Daily_Flow, B7_Daily_Flow, Well_1_Meter, Well_2_Meter, Well_5_Meter, Well_6_Meter, CIC_Blnd_Meter, R1_Meter, R3_Meter, R4_Meter, R9_Meter, B7_Meter, Well_1_Flowrate, Well_2_Flowrate, Well_5_Flowrate, Well_6_Flowrate, CIC_Conn_Flowrate, CIC_Blnd_Flowrate, R1_Flowrate, R2_Flowrate, R3_Flowrate, R4_Flowrate, B7_Flowrate, R9_Flowrate) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"


>Yes I believe that I can, i just haven't done it yet because I didn't want to type that much. I like the idea of using the command builder, but I mostly want a solution that works. I'm sorry, but I don't know what you mean by SP
>>
>Jim,
>>
>>Can you specify your InsertCommand directly or use the SP instead? Or do you prefer to use CommandBuilder?
>>
>>What database you're using?
>>
>>>Hi All,
>>>
>>>Using the code below, I am trying to insert a row of data havine 72 columns into the database. When I reach the line of code that updates the adapter an error is thrown that simply says "Syntax error in INSERT INTO statement.". When I comment out this line the code runs with no errors, but the database is obviously not updated.
>>>
>>>I have checked and double-checked all column headings for accuracy and the only thing that I question is that the first column is a PK auto increment field that I do not attempt to update, and the second column is a date field that has a default entry of now() which I also do not update.
>>>
>>>Searching the internet only reveals many conversations about whether or not the commandBuilder correctly formats the INSERT statement, but nothing as to the underlying cause or solution to the problem.
>>>
>>>Any thoughts would br greatly appreciated.
>>>
>>>Thanks,
>>>
>>>Jim
>>>
>>>
>>>         public void InsertData(CData sData)
>>>        {
>>>            OleDbConnection conn = new OleDbConnection(connectionString);
>>>            DataRow row;
>>>            DataSet oDataSet = new DataSet();
>>>            DataTable table = new DataTable(); ;
>>>            try
>>>            {
>>>                conn.Open();
>>>                table.TableName = "tblData";
>>>                OleDbDataAdapter oDataAdapter = new OleDbDataAdapter("select * from tblData", conn);
>>>                OleDbCommandBuilder cmdBuilder = new OleDbCommandBuilder(oDataAdapter);
>>>                oDataAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
>>>                oDataAdapter.InsertCommand = cmdBuilder.GetInsertCommand();
>>>
>>>                oDataAdapter.Fill(oDataSet, "tblData");
>>>                row = oDataSet.Tables["tblData"].NewRow();
>>>               
>>>               #region Columns
>>>               //row["Ave_Nitrate_Level"] = sData.Ave_Nitrate_level;  using this format for all coulmns. sData is an instantiation of a class  containing    fileds and properties for each column in the row.
>>>
>>>                oDataSet.Tables["tblData"].Rows.Add(row);
>>>                oDataAdapter.Update(oDataSet, "tblData");
>>>
>>>            }
>>>            catch(OleDbException e)
>>>            {
>>>                string errMsg = e.Message;
>>>            }
>>>
>>>            if(conn.State == ConnectionState.Open)
>>>                conn.Close();
>>>
>>>        }
>>>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform