Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB ASP.NET
Im
using the following code but some times(not all the time) i get the above error can u help
 

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.ExecuteNonQuery()
            dbconnection.Close()
 
anyone help me for this problem..
 
regards,
Sasi
 
[edit]Code block added, HTML sorted - OriginalGriff.[/edit]
Posted 11-Nov-10 4:53am
Edited 11-Nov-10 5:11am
v4
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

This error is a direct indication of the fact, that one(or several) of your parameters has length greater that the size of the corresponding data column.
 
Find out which or the parameters has the excessive length, and, either reduce its length, or change the column data size in your table.
 
Good luck.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Firstly don't do it that way - you are wide open for an SQL Injection attackm which could (accidentally or deliberately) delete your database.
Look at SqlCommand.Parameters.AddWithValue for how to do it properly.
 
That will probably also cure your problem: The chances are that some of the content of one or more of your Host, UserAgent, Browser, etc. variables holds a character or characters that the SQL does not like. Changing to parametrised queries will get rid of the problem, if so.
 
[edit]Forgot the WithValue bit of SqlCommand.Parameters.AddWithValue: SqlCommand.Parameters.Add has been depreciated - OriginalGriff[/edit]
  Permalink  
v2
Comments
Simon_Whale at 11-Nov-10 11:49am
   
is the depreciation for VB 2010?
OriginalGriff at 11-Nov-10 13:50pm
   
Simon, ParameterCollection.Add was depreciated in favour of AddWithValue with the introduction of .NET 3.0, so yes, it is very depreciated with VS2010!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

i give you the solution for that so plz go to the database and change the field data type then problem is solved check it.
  Permalink  
v2
Comments
VICK at 5-Feb-14 0:04am
   
Kindly try to be more clear. so that OP could understand your answer and get the proper help.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

It seems to me that at least one of the columns in the Table is set for fewer characters than what is being entered!
 
or you have Log Tables, so that your Primary Table (The table you are currently inserting, Updating or Deleting its data) columns Data Type length do not match The Log Table(s) columns Data Type length. So, match between those tables!
 
Regards
 
Abkasoft
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Please check your procedure paramaeter size or the column size defined in the table defination. here the problem with that is your data size exceed the variable declare in the procedure or the column size in the table
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 205
1 Sergey Alexandrovich Kryukov 165
2 jlopez788 109
3 Rob Philpott 100
4 Prakriti Goyal 97
0 OriginalGriff 6,837
1 Sergey Alexandrovich Kryukov 5,589
2 Maciej Los 3,479
3 Peter Leow 3,323
4 DamithSL 2,505


Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 5 Feb 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100