Click here to Skip to main content
11,922,320 members (39,488 online)
Rate this:
Please Sign up or sign in to vote.
See more: VB ASP.NET
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)

anyone help me for this problem..


[edit]Code block added, HTML sorted - OriginalGriff.[/edit]
Posted 11-Nov-10 5:53am
Edited 11-Nov-10 6:11am
Rate this: bad
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.
Rate this: bad
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]
Simon_Whale 11-Nov-10 11:49am
is the depreciation for VB 2010?
OriginalGriff 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
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!


Rate this: bad
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.
VICK 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
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

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

  Print Answers RSS
0 OriginalGriff 493
1 Dave Kreskowiak 285
2 Sergey Alexandrovich Kryukov 243
3 Richard MacCutchan 155
4 ppolymorphe 135
0 OriginalGriff 7,231
1 KrunalRohit 4,530
2 Sergey Alexandrovich Kryukov 3,356
3 George Jonsson 2,865
4 Suvendu Shekhar Giri 2,216

Advertise | Privacy | Mobile
Web02 | 2.8.151120.1 | Last Updated 5 Feb 2014
Copyright © CodeProject, 1999-2015
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