|
-
Oct 11th, 2001, 02:01 PM
#1
Thread Starter
Junior Member
Import date
I am trying to import excel data into a sql table useing ADO in VB.
Everything works fine but, there are two fields in the excel file that come as date and currency. My table in sql has datetime and money data type for these fields. When try to append the data
by this method
rsSql.Fields(0)=rsExcel.Fields(0)
'
'
'
'
'
rsSql.Fields(10)=rsExcel.Fields(10)
all of the fields are updated but these two fields the date and currency are not updated can some one help me out with this?
-
Oct 11th, 2001, 02:22 PM
#2
Addicted Member
I'm not totally sure here, but have you tried changing formats of the imported fields to Doubles? Most SQL style databases interpret money and time as Double precision numbers. Try using:
rsSql.Fields(0)=CDbl(rsExcel.Fields(0))
See how you get on!
-
Oct 11th, 2001, 03:46 PM
#3
Thread Starter
Junior Member
Thanks,
But the rsExcel.Fields(0) doesn't even populated with any values, when I go in debug mode there is null value. Also
the date is formatted as custom mm"/"dd"/"yyyy in excel file......
any thoughts???
-
Oct 12th, 2001, 12:34 AM
#4
Addicted Member
Hmmm...
I'm not sure about why you're not getting anything back, but the custom format doesn't matter. (You'll see what I mean if you change the format for a date to:
#,##0.0000
Last edited by Mandelbrot; Oct 12th, 2001 at 12:38 AM.
-
Oct 12th, 2001, 05:07 PM
#5
Lively Member
Dates are stored in Excel as a number since a specified date. The value that you will be transferring is probably just this number rather than the date itself.
If you use a date in SQL Server, the SQL string would normally be something like "Update MyTable Set MyDate=#12/10/2001#".
You will probably have to read the date into your program and then format it correctly for SQL Server.
In the mean time, have you thought of using the Excel object in your program to access the spreadsheet data instead. Then you can read the data as a date!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|