Update Querry

  • iv got a problem with a query to update a database.

    with the following querry i trt to update a table "RecSheet" in database "FuelMaster"

    Dim strSQL As String = "USE FuelMaster" & vbCrLf & _

    "INSERT INTO RecSheet(RecNr, OrderNr, FleetNr, SiteNr, Operator, CompanyNr)" & vbCrLf & _

    "VALUES (" & cRecNr & "," & Order & "," & cFleet & ",'" & cSite & "','" & Operator & "','" & cComp & "')"

    then i get this error.

    String or binary data would be trunvated. Change database context to 'FuelMaster'.

    in the query i do call uppon the 'FuelMaster DB'.

    Pleas if anyone knows of this type of error or have a suggestion, pleas let me know

    Tnx.

  • Dynamic sql is, in general, a very bad idea. It, amoung other things, leaves you very open to certain vulnerabilities, eg sql injection. See http://www.sommarskog.se/dynamic_sql.html for more detail

    That said...

    The error means that one of the values you are inserting is too large for the column.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply