Going nuts...a sql insert statement error...how to debug from here?

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Going nuts...a sql insert statement error...how to debug from here?

    Ugh. I'm using the following in an asp.net. I get an Syntax Error in
    INSERT INTO Statement on line Cmd1.ExecuteNonQuery().

    I've made all my database fields text (just to eliminate that as a
    potential problem). I changed all my variables in the insert statement
    to text to test as shown below. Still getting the error! I've checked
    again and again my db table and field names. Could someone please tell
    me where to go from here??? THANKS, Kathy

    Dim Conn1 As New OleDbConnection() ' conn string set globally
    Dim Adapter As OleDbDataAdapter
    Dim Cmd1 As OleDbCommand
    Dim strSQL1 As String

    strSQL1 = "INSERT INTO tblAnomaly (Date, WorkOrder, Customer, Line,
    Station, Assy, SerialNo, User, Item, Type, Problem, ProblemDesc,
    Comments, LineStop) VALUES ('08/10/03', '11233', 'XYZ', '07',
    'Station1', '865-7446-03BA', '222', 'burkek', 'ToolA not used',
    'Problem--Line Stop', 'Material Discrepancy', 'Does not meet spec',
    'none', 'true')"

    Conn1 = New OleDbConnection(strConn)
    Cmd1 = New OleDbCommand(strSQL1, Conn1)
    Conn1.Open()
    Cmd1.ExecuteNonQuery()
    Conn1.Close()


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Kathy Burke Guest

  2. Similar Questions and Discussions

    1. Syntax error in INSERT INTO statement
      I have a two table setup in fact I am doing the blog tutorial on Macromedia but with Access and asp I have two tables topic and articles I have a...
    2. Help with INSERT INTO statement
      I'm getting the following error on a query. I haven't seen this one before. Any ideas on what I'm doing wrong? Thanks. Error Executing Database...
    3. INSERT statement contains fewer items than the insert list
      The block of code below shows how I am inserting field values into my dbase table: strSQLStatement = "INSERT INTO tblArticles...
    4. error code driving me nuts
      Can any one help me please. I get this error code and i cant seem to get it right. Error Type: ADODB.Fields (0x800A0CC1) Item cannot be found...
    5. Insert Statement help
      Hello, I am having some difficulty keeping my data consistent throughout my tables. I have 3 tables that I need to be "synch'd up"....
  3. #2

    Default Re: Going nuts...a sql insert statement error...how to debug from here?

    Without knowing your error message its a bit of a guess.

    But I notice that one of your column names is 'Date' this is a reserved word
    and may be causing issues.

    Steve

    "Kathy Burke" <kathyburke40@attbi.com> wrote in message
    news:e6F%23dZ5XDHA.2020@TK2MSFTNGP10.phx.gbl...
    > Ugh. I'm using the following in an asp.net. I get an Syntax Error in
    > INSERT INTO Statement on line Cmd1.ExecuteNonQuery().
    >
    > I've made all my database fields text (just to eliminate that as a
    > potential problem). I changed all my variables in the insert statement
    > to text to test as shown below. Still getting the error! I've checked
    > again and again my db table and field names. Could someone please tell
    > me where to go from here??? THANKS, Kathy
    >
    > Dim Conn1 As New OleDbConnection() ' conn string set globally
    > Dim Adapter As OleDbDataAdapter
    > Dim Cmd1 As OleDbCommand
    > Dim strSQL1 As String
    >
    > strSQL1 = "INSERT INTO tblAnomaly (Date, WorkOrder, Customer, Line,
    > Station, Assy, SerialNo, User, Item, Type, Problem, ProblemDesc,
    > Comments, LineStop) VALUES ('08/10/03', '11233', 'XYZ', '07',
    > 'Station1', '865-7446-03BA', '222', 'burkek', 'ToolA not used',
    > 'Problem--Line Stop', 'Material Discrepancy', 'Does not meet spec',
    > 'none', 'true')"
    >
    > Conn1 = New OleDbConnection(strConn)
    > Cmd1 = New OleDbCommand(strSQL1, Conn1)
    > Conn1.Open()
    > Cmd1.ExecuteNonQuery()
    > Conn1.Close()
    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Steve Letford Guest

  4. #3

    Default Re: Going nuts...a sql insert statement error...how to debug from here?

    query analyzer and similar db clients are your friends. just set a
    breakpoint before you execute the query and spit out the sql string. cut
    and paste the sql string to your db client and attempt running the query
    from there.

    "Kathy Burke" <kathyburke40@attbi.com> wrote in message
    news:e6F%23dZ5XDHA.2020@TK2MSFTNGP10.phx.gbl...
    > Ugh. I'm using the following in an asp.net. I get an Syntax Error in
    > INSERT INTO Statement on line Cmd1.ExecuteNonQuery().
    >
    > I've made all my database fields text (just to eliminate that as a
    > potential problem). I changed all my variables in the insert statement
    > to text to test as shown below. Still getting the error! I've checked
    > again and again my db table and field names. Could someone please tell
    > me where to go from here??? THANKS, Kathy
    >
    > Dim Conn1 As New OleDbConnection() ' conn string set globally
    > Dim Adapter As OleDbDataAdapter
    > Dim Cmd1 As OleDbCommand
    > Dim strSQL1 As String
    >
    > strSQL1 = "INSERT INTO tblAnomaly (Date, WorkOrder, Customer, Line,
    > Station, Assy, SerialNo, User, Item, Type, Problem, ProblemDesc,
    > Comments, LineStop) VALUES ('08/10/03', '11233', 'XYZ', '07',
    > 'Station1', '865-7446-03BA', '222', 'burkek', 'ToolA not used',
    > 'Problem--Line Stop', 'Material Discrepancy', 'Does not meet spec',
    > 'none', 'true')"
    >
    > Conn1 = New OleDbConnection(strConn)
    > Cmd1 = New OleDbCommand(strSQL1, Conn1)
    > Conn1.Open()
    > Cmd1.ExecuteNonQuery()
    > Conn1.Close()
    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    PJ Guest

  5. #4

    Default Re: Going nuts...a sql insert statement error...how to debug from here?

    Ugh. Changed the Date field to DateEntered...just to be safe. Then I
    copied the string verbatim into an Access query and ran
    it...successfully...several times.

    The error I get in vb.net is [OleDbException (0x80040e14): Syntax error
    in INSERT INTO statement.]

    After the string worked directly in an Access query, I copied it back to
    the strSQL1 statement and tried again. SAME ERROR EVERY TIME. Where does
    one go from here?

    Any further suggestions...or workaround? Is there a string length limit
    in vb.net for an insert statement that I don't know about?

    Thanks again.

    Kathy

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Kathy Burke Guest

  6. #5

    Default Re: Going nuts...a sql insert statement error...how to debug from here?

    Went back and did an insert by adding each field on...the problem was
    the User field name...changed that and works great. It's always the
    simple things. I'm going now to memorize all the KEYWORDS!

    Thanks again for replying.

    Kathy

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Kathy Burke Guest

  7. #6

    Default Re: Going nuts...a sql insert statement error...how to debug from here?

    You can save yourself the trouble of memorizing all the keywords by putting
    square brackets around your table and column names. Example:

    SELECT [Date] FROM [User]

    The square brackets indicate that the value enclosed is a database object,
    not a reserved word.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    [url]http://www.takempis.com[/url]
    Complex things are made up of
    lots of simple things.

    "Kathy Burke" <kathyburke40@attbi.com> wrote in message
    news:u9ngNiBYDHA.1784@TK2MSFTNGP09.phx.gbl...
    > Went back and did an insert by adding each field on...the problem was
    > the User field name...changed that and works great. It's always the
    > simple things. I'm going now to memorize all the KEYWORDS!
    >
    > Thanks again for replying.
    >
    > Kathy
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Kevin Spencer Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139