String or binary data would be truncated. The statement has been terminated

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ramuksasi
    New Member
    • Oct 2010
    • 4

    #1

    String or binary data would be truncated. The statement has been terminated

    String or binary data would be truncated. The statement has been terminated.

    I'm using the following code but some times(not all the time) i get the above error can u help


    Code:
    Dim ST As String = "update MCVISITORS SET HOSTADDRESS='" & Host & "',USERAGENT='" & UserAgent & "',BROWSER='" & Browser & "',CRAWLER='" & Crawler & "', URL='" & URL1 & "', REFERRER='" & Referrer & "', VISITCOUNT='" & VisitCount & "', ORIG_REFERER='" & OriginalReferrer & "', ORIG_URL='" & OriginalURL & "', PAGE_COUNT='" & pageno & "', TOTALTIME='" &; ttime & "' WHERE VISITORID='" & vid & "'"

    dbcommand = New SqlCommand(ST, dbconnection)
    dbcommand.Execu teNonQuery()
    dbconnection.Cl ose()

    anyone help me for this problem..

    regards,
    Sasi
    Last edited by Frinavale; Nov 19 '10, 02:05 PM. Reason: Added the description of the error to the thread.
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    You are sending a value to a field that exceeds the size allocated for that field.
    Address is too long or something like that

    Comment

    • jeffstl
      Recognized Expert Contributor
      • Feb 2008
      • 432

      #3
      code green is correct. To clarify you need to check the actual column properties in the table MCVISITORS on the database.

      If you have the power a quick fix would be to just increase the number of characters you can save in those columns ;)

      But likely they were set for a reason, so a better option might be checking the length of the problem data before you pass it into your SQL, and if its too long then wherever that data is coming from needs to be re-checked or changed.

      If the table columns have the default character length settings, and were never even looked at when the table was designed, then now is probably a good time to check what they should be, and set them up, if it doesnt matter or the length of your data is always going to be unknown then set them to the maximum I guess :)

      Comment

      Working...