C# .NET - Error While retrieving data from database(Access Database)

Asked By ALOK RANJAN on 16-Apr-12 07:07 AM
hi everyone..........
                              I have a problem that In my database There is a Column and that col. contain value(100 Km).
 but when we fetching record from database this error come out ,please tell me solution ASAP.

Input string was not in a correct format.Couldn't store <100  km> in OpeningReading Column.  Expected type is Int32.

Thanks & Best Regards

Chintan Vaghela replied to ALOK RANJAN on 16-Apr-12 07:25 AM



You can not store string value to int field


100 km is string

So you have two choice

1.Store only 100 in field

2.Change field type int to string




Hope this helpful!



ALOK RANJAN replied to ALOK RANJAN on 16-Apr-12 07:29 AM
I have already change datatype and datatype is Text. of that column. bcoz it,s access database. and Text datatype can hold int +string both
dipa ahuja replied to ALOK RANJAN on 16-Apr-12 07:59 AM
"100 km " is not an valid no.

Store the value in the no. format that means you have to remove "km"

and then pass the query :

"Select * from table1 where column2 < 100"