all groups > sql server programming > september 2006 >
You're in the

sql server programming

group:

SQL Syntax - Incorrect Syntas near '1'


SQL Syntax - Incorrect Syntas near '1' Greg P.
9/13/2006 5:08:02 PM
sql server programming:
I have created an insert statement by concatenation in VS2005 going to
SQLSwerver 2005. If i copy the string out of my watch window and run it as a
query on my Database it works fine. If I do an execute non-query on it I the
the above error.

I have adjusted the syntax by removing all of the variables I was using and
I still get the same error. I added constants (never using a #1) and still
get the same error. The code is as follows. I blow up on line ExecuteSQL =
cmdExecuteSQL.ExecuteNonQuery(). So the connection opens, the command is
assigned correctly so it must be the string right? Wrong the string works
fine in a Query in Sql Server 05. I have no idea what the problem is?

Dim strSql as string = ...
Dim strCnn As String = My.Settings.csStrategy.ToString
Dim CnnStrat As SqlConnection = New SqlConnection(strCnn)
Try
CnnStrat.Open()
Dim cmdExecuteSQL As SqlCommand = New SqlCommand(strSql, CnnStrat)
cmdExecuteSQL.CommandText = CommandType.Text

ExecuteSQL = cmdExecuteSQL.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.ToString)
Finally
CnnStrat.Close()
End Try

Re: SQL Syntax - Incorrect Syntas near '1' Warren Brunk
9/13/2006 5:12:41 PM
It would help to see the Query or atleast how you are using the
ExecuteNonQuery...




--
/*
Warren Brunk - MCITP - SQL 2005, MCDBA
www.techintsolutions.com
*/


[quoted text, click to view]

Re: SQL Syntax - Incorrect Syntas near '1' Stu
9/14/2006 3:47:23 AM
I blame gremlins.

Invisible code, invisible causes :)

[quoted text, click to view]
Re: SQL Syntax - Incorrect Syntas near '1' ML
9/14/2006 3:53:02 AM
Nasty. But to the point. :)


ML

---
Re: SQL Syntax - Incorrect Syntas near '1' glen
9/14/2006 7:30:01 AM
sounds like a PEBKAC error
--
glen


[quoted text, click to view]
Re: SQL Syntax - Incorrect Syntas near '1' Erland Sommarskog
9/14/2006 8:30:22 AM
Greg P. (GregP@discussions.microsoft.com) writes:
[quoted text, click to view]

The main problem at this point is that you don't give as the SQL string.

I have a hinch that what it might be, but without seeing your query string,
I don't want to wander into speculations.




--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
Re: SQL Syntax - Incorrect Syntas near '1' Stu
9/14/2006 10:37:57 AM
When I used to work phone help desk, we'd call it an ID-Ten-T error.



If you don't get it, replace the word in the middle with the number.
Ahh, great fun :)

But seriously, if the OP is still reading this, post the code, and I'm
sure you'll get lots of suggestions to help.

Stu


[quoted text, click to view]
AddThis Social Bookmark Button