Thank you.
then you can use DAO to put data into appropriate tables
--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com
"diaExcel" <diaE...@discussions.microsoft.com> wrote in message
news:A1D90004-B6A9-4C15...@microsoft.com...
Which is worse: the OP posting an ADO question in the DAO group or
posting an DAO reply to an ADO question? ;-)
Jamie.
--
I want to import the Excel file in Access database using ADO in VB6.0, can I
do that and how?
Thank you.
"Alex Dybenko" a scris:
--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com
"diaExcel" <diaE...@discussions.microsoft.com> wrote in message
news:B6398DA3-7E0A-4778...@microsoft.com...
You can connect to the Excel file through ADO to retrieve the
information, given that the information is in some kind of order.
Here's some results of a short web search
http://www.ozgrid.com/forum/showthread.php?t=17158
http://support.microsoft.com/kb/326548/en-us
http://support.microsoft.com/kb/262537/en-us
Let's take it a step further. Say you've got the file xlsfile.xls
somewhere, where the headers are stuffed at the top of the sheet (sheet
named xlsfile, too), I think you should be able to do something like
this:
Dim cn As ADODB.Connection
Dim RecsAffected As Long
Dim SQLString As String
Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\<path and name of>.xls;" & _
"Extended Properties='Excel 8.0;HDR=Yes'"
cn.Open
SQLString = "INSERT INTO TargetTable In " & _
"'c:\<path and name of>.mdb' " & _
"SELECT * FROM [xlsfile]"
cn.Execute SQLString, RecsAffected, adCmdText + adExecuteNoRecords
Debug.Print RecsAffected
I think you can also be a bit selective with ranges, say
...SELECT * FROM [xlsfile$A1:X120]"
xlsfile here represenging sheet name.
--
Roy-Vidar
Thank you
"RoyVidar" a scris:
diaExcel wrote:
>Thank you so much!!!
>I have another question....
>in VB6.0 in a form I have a DataGrid which is populated with data from
>Access, but now I want to add all rows from this datagrid in a different
>table in Access, how can I do that, because I've seen that I have to add row
>by row and I don't want to in that way, I want that all the rows in a single
>step to be added...
>
>Thank you
>
>"RoyVidar" a scris:
>
>> > Hi,
>> >
>[quoted text clipped - 37 lines]
[snipped stuff related to previous question]
Dear diaExcel,
though there probably are poeple frequenting this NG that are familiar
with objects of classic VB, I think you probably have better chances
of getting a reply in an NG dedicated to classic VB.
I don't know anything about the control you mention, as it doesn't
exist
in the product for which this NG is dedicated (Ms Access), but, say
you've populated it trough a select (apply WHERE clause as appropriate)
SELECT col1, col2, ...colN FROM SomeTable
you should be able to do something like (air code)
INSERT INTO NewTable
SELECT col1, col2, ...colN FROM SomeTable
- using the first select.
Or, to create a new table, something like
SELECT col1, col2, ...colN
INTO NewTable
FROM SomeTable
You should be able to fire some of this off on an ADO connection to
the db.
But adding redundant data etc, begs the question whether you've chosen
the most optimal design.
--
Roy-Vidar