.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Insert statement giving me syntax error

Posted By:      Posted Date: September 22, 2010    Points: 0   Category :ASP.Net

Good evening,


I have a MS Access table with the "ModelID" column set as AutoNumber and primary key. The ModelID is set as Field Size --> Long Integer, New Values --> Increment, Format --> General Number, Indexed --> Yes (No Duplicates).

Here is the code i am trying to execute, and is giving me an exception -> insert into syntax error:

string strInsert = "INSERT INTO tbl_Models (fName, lName, Image, Answer1, Answer2, Answer3, Answer4, Answer5, Votes, ImageHead, Age, Program, StudentID, PhoneNumber, EMail) VALUES (@fName, @lName, @Image, @Answer1, @Answer2, @Answer3, @Answer4, @Answer5, @Votes, @ImageHead, @Age, @Program, @StudentID, @PhoneNumber, @EMail)";
        OleDbCommand cmdInsert = new OleDbCommand(strInsert, myCon);

        cmdInsert.Parameters.AddWithValue("@fName", txtFirstName.Text.ToString());
        cmdInsert.Parameters.AddWithValue("@lName", txtLastName.Text.ToString());
        cmdInsert.Parameters.AddWithValue("@Image", FileUploadBody.FileName.ToString() + sRandomBody);
        cmdInsert.Parameters.AddWithValue("@Answer1", txtWhyBeAModel.Text.ToString());
        cmdInsert.Parameters.AddWithValue("@Answer2", "");
        cmdInsert.Parameters.AddWithValue("@Answer3", "

View Complete Post

More Related Resource Links

Giving syntax error for CASE statement using VS (SSAS) 2008 designer


Hi All,

I am writing following CASE statement in Data Source View-> Righ click measure table "xyz" -> and select "Edit Named Query"








Insert Error not helpful



I am using VS2010

When I try to updated or insert a record in my User table I am getting an error that does not make sense to me and I cannot figure out what is wrong.

Also, when I try to insert a new record I get a validation error saying that the Id is required. However it is an identity field in the db so it should not be necessary to send it to the server.

Could you please shed some light?


An error has occurred.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Microsoft.Web.UI.WebControls.EntityOperationException: An error has occurred.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace:

[EntityOperationException: An error has occurred.]
   Microsoft.Web.UI.WebControls.DomainDataSourceView.PerformCudOperation(ChangeSetEntry operation, Action`1 operationPerformingEvent, Action`1 operationPerformedEvent) +331
   Microsoft.Web.UI.WebControls.DomainDataSourceView.UpdateObject(Object oldEntity, O

Json Deserialization is giving error in IronPython



Have anyone tried json deserialization. When I tried:

>>> import json

>>> json.loads('["foo", {"bar":["baz", '"Test", 1.0, 2]}]')

I got following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\IronPython 2.6 for .NET 4.0\Lib\json\__init__.py", line
 307, in loads
  File "C:\Program Files\IronPython 2.6 for .NET 4.0\Lib\json\scanner.py", line
42, in iterscan

Syntax error (missing operator) in query expression

Good Day Gurus!

I have a Excel user application which has a user form (named 'Registo') that displays criteria and an image that has been entered in it's corresponding spreadsheet. This works the way it should.  There's also the ability to search the spreadsheet via a form (by clicking 'Pesquisar' button) this opens a search form. However, I having a bit of a problem with it. When I try to search for something it basically doesn't do anything at all. It just sits there. So I tried to debug it and I think I'm having a problem with either the JET db engine or somethign with teh query or maybe I don't have the correct reference.

I 'borrowed' this Excel application from another forum because it's exactly what I'm looking for! However, I suck at vb.

So I was hoping somebody could take a look at the code and see if I'm missing something?  I'm kinda' desparate to get this working because I'm been trying to figure it out for days and I'm running out of time.  Cry
Option Explicit

'constantes para auxiliar na verificação do código
Private Const Ascendente As Byte = 0

Error by insert new item in dataview sharepoint designer



doesn't any1 know the answer of my question?

i'm trying to create a data view with the edit, delete and insert function.

the edit and delete works fine. only the insert gives me this error:

The data source control failed to execute the insert command.

plz help?

HoverMenuExtender is giving me the error SYS.Extended.UI.PositioningMode.Aboslute is null or not an


Here is my Code....Any thoughts on what I am doing wrong? I pulled in the Ajax Tookit based on the instructions then was following the HoverMenuExtender tutorial.

Any info would be greatly apprecated!

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">
<asp:ScriptManager ID="asm" runat="server" />
      <asp:Repeater ID="rpOrders" runat="server">
          <br />
          <asp:Panel ID="myPanel" runat="server" Width="400px" BackColor="Lime" BorderWidth="1px">
              <%#DataBinder.Eval(Container.DataItem, &quo

Incorrect syntax near 'GO' error while running a sql script ?


I am using Visual Studio 2008

I have one Database A

now i want to create Database B just like Database A

I generated a script of Database A

and created fresh Database B

Now, when i try to run the generated script against Database B, i get this error, why ? how to fix it ?

sql error

For your information:

I have checked in my script it is:


and i have also tried to save the sql script in notepad as: ANSI, UTF-8 and UNICODE

and then i copied from txt file to query but still doesn't work and getting the same error

and these are the option that i selected/used while creating my script:


syntax error in calling mailhelper class??


I use to program with VB.NEt. I am just learning C#.  I need to learn C# b/c I am a SharePoint developer and Admin and thats what SharePoint is coded from.


so I am trying to create a simple form that sends an email but am getting an error with calling this function:

       mailHelper.SendMailMessage("admin@pointeightpower.com", "jstevens@pointeightpower.com", null, null, "August Heat Stress", String.Concat(txtSupervisorName.Text.Trim, "reviewed this month's training on ", System.DateTime.Now));


it says param string has some invalid arguements. I dont know why. it works in VB.Net. any help? Thanks

can't to insert value to EXCEL folder get error

Hi Can't to insert value in EXCEL folder get error   The Microsoft Jet database engine could not find the object 'Sheet1$'.  Make sure the object exists and that you spell its name and the path name correctly.   there is a code      The Microsoft Jet database engine could not find the object 'Sheet1$'.  Make sure the object exists and that you spell its name and the path name correctly. {        string sConnectionString = null;     sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\\Users\\12.xls';Extended Properties=\"Excel 8.0;\"";        System.Data.OleDb.OleDbConnection objConn = new System.Data.OleDb.OleDbConnection(sConnectionString);        objConn.Open();          //Add two records to the table.        System.Data.OleDb.OleDbCommand objCmd = new System.Data.OleDb.OleDbCommand();        objCmd.Connection = objConn;        objCmd.CommandText = "Insert into [Sheet1$] (FirstName, LastName)" + " values ('Bill', 'Brown')";        objCmd.ExecuteNonQuery();        objCmd.CommandText =

INSERT Statement Inside a UDF?

I am using SQL Server 2005.  I know you can not put INSERT or UPDATE statements in a UDF.  I am looking for an alternative to getting the end result I need since this call has to go at a specific point in the code or it will never work.  I have a UDF which packs smaller boxes into a bigger box efficiently.  The UDF typically runs and creates as many bigger boxes as possible until all smaller boxes are used and then it returns a TABLE variable back to a stored procedure.  I need to insert a record into a new table at the point where each bigger box is full before it moves on to the next bigger box.  There is only a couple alternatives I can see but don't really know if each is possible.  I am open to an ideas: 1. Call a stored procedure from the UDF which executes the insert statement 2. Using EXECUTE to perform the insert statement 3. Re-write the UDF as a stored procedure.  It must be able to table two inputs and return a table which can be unioned with two other views. 4. Anything Else UPDATE: Scratch idea #1 since it says I can only call other functions or extended stored procedures UPDATE: Scratch idea #2 as it did not work

INSERT statement with OUTPUT clause, referencing outer query columns

I have a problem to solve and I have run into what appears to be a limitation of TSQL.  I have looked around and did not find much on this subject, so I apologize if this duplicates another post.  I am using SQL Server 2008. From what I have read on BOL, when you are performing a DELETE or UPDATE statement, you can reference unaffected columns from the outer query in the OUTPUT clause, but this is apparently not allowed in an INSERT statement. I am working on a process that will create new copies of existing records - essentially, the user can create a whole new copy of a set of records, and the process requires that I track both what the original PK values were and the corresponding PK values for the new rows. This example will hopefully spell out my problem.  This script shows two tables, [Primary_Object] and [Secondary_Object].  Not shown here are multiple tables that rely on [Secondary_Table], which is why I have to be able to track this info. This first script shows the setup of the tables involved and the data involved: /* create test data */ create table primary_object ( primary_object_id int identity(1,1), parent_object_id int, name char(1)) create table secondary_object ( secondary_object_id int identity, primary_object_id int, amount money) insert into primary_object (parent_object_id, name) select 0, 'A' insert into secon

Strange Problem - SSIS Fails with "Syntax error, permission violation, or other nonspecific error".

Hello, I have a strange issue while I am deploying a package to one of the environment server. I have 2 XML Source, in the DataFlow, and one will extracted based on a value of variable that is passed from run time (package is executed from a Job) and other will be extracted all time. The next Step I have is a Execute SQL Task in ControlFlow wihich will execute after DataFlow. This has 2 input parameters and some SQL query that uses the param. Now this one fail on the target environment with below error: failed with the following error: "Syntax error, permission violation, or other nonspecific error". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. I got the error when I did a SSIS Text File Log. Note: If I run the package in BIDS with the same XML files it work. Also when I deploy the package to my Dev Server it works. When I compare the Dev DB with the target environment DB - Both are same. The Service Acount has permission - as I can see the DataFlow task completed. Another Point: The XML Load Data Flow that executes based on the Variable Value does not execute on target environment, even if the value is passed as "True" (It is Boolean Type) But this variable is NOT an input for the Execute SQL task that fails. I am not sure w

Insert Into SQL Server inside a For Each - Next Statement

I have the following code to For each Item in the file uploader, Insert Into database.... but It doesnt work in the For Each Statement but if i take it out of the For Each statement it works.   For Each item As AttachmentItem In Attachments1.Items            Dim objConn2 As New SqlConnection("Data Source=XXX")            objConn2.Open()            Dim objCmd2 As New SqlCommand("INSERT INTO clientport (name, event, date1, username, password, path)" & "VALUES (@name, @event, @date1, @username, @password, @path)", objConn2)                                 objCmd2.Parameters.AddWithValue("@name", clientname.Text)            objCmd2.Parameters.AddWithValue("@event", [event].Text)            objCmd2.Parameters.AddWithValue("@date1", [date].Text)            objCmd2.Parameters.AddWithValue("@username", username.Text)  &nbs

SSIS Package working on SQL Client Machine but when trying to run on SQL Server machine giving error

Hi We are trying to run SSIS package on sql server machine but sometimes it is giving error for data flow task containing Script Component. Error is - [SSIS.Pipeline] Error: component "SCR DimensionRelation" (1) failed the post-execute phase and returned error code 0x80004002. This error is not coming continuously. And also not for specific DFT. It comes for different DFTs as we rerun the package. Can anybody help me on this? We are using SQL server 2008. We are not getting any error on client machine :(:(

Insert columns into GridView and rendercontrol error

Hi I´m inserting columns into a gridview at run time using: gvRageReport.Columns.Insert(index, column) When I render the gridview in orther to export to excel all the excel columns are empty except the new insert columns, but when I add the new columns using gvRageReport.Columns.Add(column) the excell is exported successfully.Any idea?

SQL ServerDestination error - Unable to prepare the SSIS bulk insert for data insertion.

Having searched the forum, this one clearly has form... However beyond assisting those who have fallen at the first hurdle (i.e. forgetting/not knowing that they cannot execute the package remotely to the instance of SQL Server into which they are inserting), the issues raised by others have not been addressed. Thus I am bringing nothing new to the table here - just providing an executive summary of problems which others have run into, written about, but not received answers for.   First the complete error: Description: Unable to prepare the SSIS bulk insert for data insertion.  End Error  Error: 2008-01-15 04:55:27.58     Code: 0xC004701A     Source: <xxx> DTS.Pipeline     Description: component "<xxx> failed the pre-execute phase and returned error code 0xC0202071.  End Error  DTExec: The package execution returned DTSER_FAILURE (1).  Started:  4:53:34 AM  Finished: 5:00:00 AM  Elapsed:  385.384 seconds.  The package execution failed.  The step failed.   Important points It mostly works - It produces no error more than 9 times out of 10. It fails on random dataflows - My package has several dataflows, (mostly) executing concurrently. Where the error occurs it does not do so on the same dataflow each time: on one run it'll fail on dataflow A whilst B,C,D and E succeed, then A-E will all succeed (and continue doing so for the next ten runs thereafter), and

error in insert hebrew data into sql server 2005

Hello, am trying to insert data in hebrew language into sql server 2005 but it appears like this ???????????? can i know how i can fix the problem plz???? thank u
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend