G
Guest
I have created an insert statement by concatenation in VS2005 going to
SQLServer 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
Thanks,
SQLServer 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
Thanks,