Please help with an overflow error with database

D

Dan

Hi. I'm having a problem with searching a databse entry. I'm new to dotnet
and still trying to figure some things out.

In order to locate a row in an access databse file .mdb, i am using this
call

Dim dr As DataRow
dr = Me.DsMaster.Tables("MasterList").Rows.Find(Me.txtScan.Text)

where me.txtscan.text is a value from 2 to 9323493000236.
when searching for smaller values i have nu problem. but when i search for
the larger values i get an error.

An unhandled exception of type 'System.OverflowException' occurred in
mscorlib.dll
Additional information: Value was either too large or too small for an
Int32.

I have tried converting but i still get the same error. I need to be able to
search for these values as they are unit ID numbers. Is there a way to do
this?
Perhaps there is a better way to search the database for the row containing
the data? Any help would be great.

Thanks alot

Dan Butler
(e-mail address removed)
 
O

One Handed Man [ OHM# ]

Well, look at the size of the number

9,323,493,000,236

Int32:=

2,147,483,647

There is your problem.

Regards - OHM
 
D

Dan

Thanks for the responses!
Maybe if i explain what i am working with, perhaps someone could help me
out.
I have a database with 15,150 rows. The numbers in column one, representing
an ID range from 2 to 9323493000236. All uniquie entries, no duplicates.
Since there are only 15,000 rows (or so) you can tell that alot of number
skipping is going on.
The way it wors is the user enters in a barcode number via hand or scanner.
The program then is supposed to search for the value. However, when i use
the find i spoke of in my earlier post, i was getting the overflow error. I
figured since the data was within the acceptable amount of rows, I would be
able to search for it? I think i am probably going about searching for the
corresponding row (or index) the wrong way.

Thanks again
Dan Butler
(e-mail address removed)
 
C

Cor

Hi Dan,

Why not first fill a little dataset with a "where" clause or use a
datareader with that?

Would give you a lot of more performance I think

Cor
 
A

Austin Wise

That would be a good idea unless you where searching through the data with a
lot.
Another option would be to use a DataView.
 
R

Ron Allen

Dan,
What is the type of your primary key column? You are passing a string
to search with boxed as an object which may be causing some of the problems.
Try calling Convert.Toxxx(Me.txtScan.Text) where xxx is the type of the
column.
If the column is of type char instead of varchar you may have to pad the
string appropriately first.

Ron Allen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top