Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
while i fetch the data from data base , i got the error :

length cannot be less than zero

parameter value : length
Posted
Updated 3-Jan-22 11:14am
Comments
Sergey Alexandrovich Kryukov 7-Apr-14 1:42am    
Well, think by yourself: can a length of something be less then zero? :-)
—SA
SOHAM_GANDHI 7-Apr-14 1:57am    
before fetching the data from database, somewhere you calculate the length of database (in terms of records), thats why it showing error.
SOHAM_GANDHI 7-Apr-14 1:58am    
Better way is that, make permanent default row(0), insert default values.
avelsamy 7-Apr-14 4:49am    
yeah right i m fetching data through grid view,

there i m using this code

If e.Row.RowType = DataControlRowType.DataRow Then
...
...
end if
SOHAM_GANDHI 7-Apr-14 4:58am    
don't match the row type, check the data exists or not.

1 solution

Quote:
length cannot be less than zero
Quite clear. Somewhere you are accessing the length property of some Object, which is not having any data in it. So, it would throw you exception.

Debug your code and see the line where it throws the exception. Before doing anything with the length, just check if has any data or not.
 
Share this answer
 
Comments
avelsamy 7-Apr-14 4:49am    
yeah right i m fetching data through grid view, there i m using this code If e.Row.RowType = DataControlRowType.DataRow Then ... ... end if
So, found the problem?
avelsamy 7-Apr-14 6:58am    
i found the solution , thank you
Great. :) Please accept this answer.

Thanks,
Tadit

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