Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB: Excel to database dealing with empty cells

Status
Not open for further replies.

Ramy27

Technical User
Apr 26, 2005
63
GB
I’m copying some tables from Excel to DB using VB code. There is a particular column in the Excel sheet that is supposed to be numbers. But on some occasions there isn’t a number (empty field). But this doesn’t mean that it’s zero. My SQL statement created in VB looks something like this:

INSER INTO Pressure (Type, Depth, Pressure) Values(‘Well’,, 25)

This gives an error.
How do I fix this?


 
Try to use vbNullString when no data in the cell.
Replace INSER with INSERT

vladk
 
1) sorry INSER was just a mistake when I copied.

2) where do I use vbNullString ?

 
Try something like that:

INSER INTO Pressure (Type, Depth, Pressure) Values(‘Well’,vbNullstring, 25)

 
Hi vladk..

I'm trying to create a import function for my app to read in the info from excel and place it into a database.. But I seem to have run into a wall.. I get an error message back saying the Microsoft Jet database engine could find the path or the file name is misspelled.. Can you please place yur code for accessing the Excel file here? Thank..
 
ICTECH,

It will probably make more sence if you could post your code for accessing Excel file. Highlight the error line. And me or somebody will correct the problem.

I usually use complex combination of FolderBrowserDialog, OpenFileDialog, and textboxes to access a file.

vladk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top