I want to perform an UPDATE query but i'm getting this error:
This is my Sub in vb.net:
Public Sub changeStatus()
Dim Sqlstr As String
Dim connectionString As String = "server=xxxx;uid=xxxx;pwd=xxxx;database=xxxx"
Dim strtTime As String
Dim endTime As String
strtTime = DateTime.Today.ToString("yyyy/MM/dd") & " " & "06:15:00"
endTime = DateTime.Today.ToString("yyyy/MM/dd") & " " & "18:15:00"
Sqlstr = " UPDATE dbo.VAC_LineStatus "
Sqlstr = " SET SET Status = @Status "
Sqlstr = " WHERE (Line IN "
Sqlstr = " (SELECT VAC_JSINFO.LINE "
Sqlstr = " FROM dbo.VAC_LineStatus INNER JOIN "
Sqlstr = " VAC_JSINFO ON dbo.VAC_LineStatus.Line = VAC_JSINFO.LINE "
Sqlstr = " WHERE (VAC_JSINFO.COLLECTDATE > '" & strtTime & "') AND (VAC_JSINFO.COLLECTDATE < '" & endTime & "') AND "
Sqlstr = " (VAC_JSINFO.KYUERR1 >= 0) "
Sqlstr = " GROUP BY VAC_JSINFO.LINE, VAC_LineStatus.Line HAVING(SUM((VAC_JSINFO.KYUERR1 + VAC_JSINFO.VISION1 + VAC_JSINFO.KEIJYOU1) * VAC_JSINFO.UNITCOST) > '25')))"
Sqlstr = " HAVING (SUM((VAC_JSINFO.KYUERR1 + VAC_JSINFO.VISION1 + VAC_JSINFO.KEIJYOU1) * VAC_JSINFO.UNITCOST) > '25'))) "
Using connection As New SqlConnection(connectionString)
Dim cmdInsert As New SqlCommand(Sqlstr, connection)
cmdInsert.Parameters.Add("@Status", Data.SqlDbType.NVarChar).Value = 1
connection.Open()
cmdInsert.ExecuteNonQuery()
End Using
End Sub
When i execute the query in SQL Server, it's working fine but why it get error when trying to execute using vb.net?
Can someone help me please...