Click here to Skip to main content
15,885,952 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Updated 11-Nov-10 5:11am
v4

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.
 
Share this answer
 
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]
 
Share this answer
 
v2
Comments
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!
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
 
Share this answer
 
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.
 
Share this answer
 
v2
Comments
VICK 5-Feb-14 0:04am    
Kindly try to be more clear. so that OP could understand your answer and get the proper help.
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
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900