Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Read data from EXCEL to database using VB
Author:
Rakesh
E-mail:
Click to e-mail author
Submitted:
6/1/2007
Version:
VB6
Compatibility:
VB6
Category:
Forms
Views:
42857
To read data from EXCEL to database using VB.
Declarations:
Dim xl As New Excel.Application Dim xlsheet As Excel.Worksheet Dim xlwbook As Excel.Workbook Dim Con As New ADODB.Connection Dim rs As New ADODB.Recordset
Code:
Private Sub updatOrdTab_Click() Dim Val1, Val2, val3, prmno, flag1 As Integer Dim val6 As Single Dim remarks As String Dim MyDate As Date Con.Open Set xlwbook = xl.Workbooks.Open("D:\fstock12.xls") Set xlsheet = xlwbook.Sheets.Item(1) Val1 = 3 prmno1 = 2 flag1 = 2 'flag Con.BeginTrans 'stri = xlsheet.Cells(Val1, 2) Do Until Val1 = 774 val3 = xlsheet.Cells(Val1, 1) Val2 = xlsheet.Cells(Val1, 2) val6 = xlsheet.Cells(Val1, 9) remarks = " Opening Stock" MyDate = "30-MAY-2007" cmbVal.AddItem xlsheet.Cells(Val1, 9) Con.Execute "Insert into TABLE values (2, " & xlsheet.Cells(Val1, 1) & ", " _ & " " & xlsheet.Cells(Val1, 2) & ", '" & Format(MyDate, "dd-mmm-yyyy") & "', " _ & " " & xlsheet.Cells(Val1, 9) & ", " & flag1 & ", '" & Trim(remarks) & "')" Val1 = Val1 + 1 Loop Con.CommitTrans End Sub
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement