I have vb6.0 code. When I click on run button the code pull data from database and show it in flexgrid. Here is the code
Private Sub run_Click()
Dim con As New ADODB.Connection
Dim msgr As msflexgrid
Set con = New ADODB.Connection
con.ConnectionString = "Provider=MSDAORA.1;User ID=SYSTEM;password=ora123;Persist Security Info=False"
con.Open
Set rs = con.Execute("select * from sample where " & _
" date_time = to_date('" & Format(dtpicker.Value, "dd/MMM/yy") & "','dd-mon-yy')")
Dim r As Integer
With msflexgrid
.TextMatrix(0, 0) = rs.Fields(0).Name
.TextMatrix(0, 1) = rs.Fields(1).Name
.TextMatrix(0, 2) = rs.Fields(2).Name
r = 1
Do Until rs.EOF
.TextMatrix(r, 0) = rs.Fields(0)
.TextMatrix(r, 1) = rs.Fields(1)
.TextMatrix(r, 2) = rs.Fields(2)
r = r + 1
.Rows = .Rows + 1
rs.MoveNext
Loop
End With
End Sub
I wanted to export these flexgrid data into excel. I created some code to open excel application Below is the code.
Private Sub cmd1_Click()
Dim exl As Excel.Application
Dim wkb As Excel.Workbook
Dim wks As Excel.Worksheet
Dim i As Integer 'Counter
Dim j As Integer 'Counter
Set exl = New Excel.Application
Set wkb = exl.Workbooks.Add
Set wks = wkb.Sheets(1)
exl.Visible = True
End Sub
Edited by macosxnerd101: Please,

New Topic/Question
Reply




MultiQuote



|