Hi Good Guys
I need your help. Please help me.
I am trying to create INSERT SQL using WHERE syntaxing in order to ensure no duplication with the SQLCMD.PARAMETER but the WHERE clause generate this error message:
Incorrect syntax near the keyword 'Where'.
----------------------------------------
Here are the coding:
Code:Dim strSql As String strSql = "Insert into tblCustomers " strSql &= "(CustomerID, ContactName,Address,City,PostalCode,Country)" strSql &= " Values (@CustIdValue, @ContNameValue, @CustAddrValue, @CityValue, @PostCodevalue, @CountryValue)" strSql &= " Where CustomerID <> @CustIDValue " <--- error sqlconn = New SqlConnection(connstr) sqlconn.Open() sqlcmd = New SqlCommand(strSql, sqlconn) With sqlcmd.Parameters .AddWithValue("@CustIDValue", CType(Me.txtCustID.Text, String)) .AddWithValue("@ContNameValue", CType(Me.txtContName.Text, String)) .AddWithValue("@CustAddrValue", CType(Me.txtCustAddr.Text, String)) .AddWithValue("@CityValue", CType(Me.txtCity.Text, String)) .AddWithValue("@PostCodeValue", CType(Me.txtPostCode.Text, String)) .AddWithValue("@CountryValue", CType(Me.txtCountry.Text, String)) End With





Reply With Quote