D
dawg1998
I am attempting to create a record that has a uniqueidentifier
datatype. I am receiving the following error each time I attempt the
Insert:
Incorrect syntax near '-'
The following is the code I am using to execute the Insert:
Dim strSQL As String
Dim objConn As SqlConnection
Dim objCmd As SqlCommand
Dim idAccountID As Integer = 1
Dim UserID As String = ddlUserID.SelectedValue 'from a
dropdownlist
Dim idUserTypeID As Decimal = 1
strSQL = "INSERT INTO tblTable (idAccountID, UserID,
idUserTypeID) VALUES (" & idAccountID & ", '" & UserID & "', " &
idUserTypeID & ");"
Try
objConn = New
SqlConnection(ConfigurationManager.ConnectionStrings("connDatabaseConnection").ConnectionString)
objCmd = New SqlCommand(strSQL, objConn)
objConn.Open()
objCmd.ExecuteNonQuery()
Catch errError As Exception
lblSystemNotification.Text = errError.Message
Finally
objCmd.Dispose()
objConn.Dispose()
End Try
Any ideas how to Insert a uniqueidentifier value into a table without
getting this error?
datatype. I am receiving the following error each time I attempt the
Insert:
Incorrect syntax near '-'
The following is the code I am using to execute the Insert:
Dim strSQL As String
Dim objConn As SqlConnection
Dim objCmd As SqlCommand
Dim idAccountID As Integer = 1
Dim UserID As String = ddlUserID.SelectedValue 'from a
dropdownlist
Dim idUserTypeID As Decimal = 1
strSQL = "INSERT INTO tblTable (idAccountID, UserID,
idUserTypeID) VALUES (" & idAccountID & ", '" & UserID & "', " &
idUserTypeID & ");"
Try
objConn = New
SqlConnection(ConfigurationManager.ConnectionStrings("connDatabaseConnection").ConnectionString)
objCmd = New SqlCommand(strSQL, objConn)
objConn.Open()
objCmd.ExecuteNonQuery()
Catch errError As Exception
lblSystemNotification.Text = errError.Message
Finally
objCmd.Dispose()
objConn.Dispose()
End Try
Any ideas how to Insert a uniqueidentifier value into a table without
getting this error?