Check out and contribute to CodePedia, the wiki for developers.

Access databases and VB

Moderators: Gogi
Number of threads: 746
Number of posts: 1571

This Forum Only
Post New Thread

Report
import excel to access database in vb6.00 Posted by slowjeff on 16 Nov 2009 at 11:16 AM
can anyone help me with the code.
am trying to import the content of an excel sheet to my access database using common dialog in vb6. i tried this code below but is not working ........

Private Sub sLoadExcel()
If CommonDialog1.FileName = "" Then Exit Sub
Dim exc As Object
Set exc = CreateObject("Excel.Application")
exc.Workbooks.Add (CommonDialog1.FileName)
exc.Visible = True

'Dim i As Integer
For i = 0 To exc.Row - 1
With rstAS400
.AddNew
.Fields![STUDID] = exc.cells(i, 1)
.Fields![FNAME] = exc.cells(i, 2)
.Fields![LNAMSE] = exc.cells(i, 3)
.Fields![SEX] = exc.cells(i, 4)
.Fields![LDOB] = exc.cells(i, 5)
.Update
Next i
End With
End Sub

please help me out.



 
Popular resources and forums for programmers on Programmersheaven.com
Assembly, Basic, C, C#, C++, Delphi, Java, JavaScript, Pascal, Perl, PHP, Python, Ruby, Visual Basic
© Copyright 2009 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Publisher: Lars Hagelin. Read the latest words from the publisher here.
Be the first to sign up for Lars Hagelin’s In-depth Outsourcing Newsletter here.
bootstrapLabs Logo A bootstrapLabs project.