|
-
Sep 26th, 2003, 01:49 AM
#1
Thread Starter
Member
Using Data Report with MySQL *resolved*
I'm trying to make a report based on information from a database (in my case, it's MySQL)...
I tried searching in the MSDN, and only got info about making a report from access (*.mdb) files...
All the necessary parameters are set during design time...
Is there another way that i can extract info from a database like MySQL?
I'm currently using connection strings and SQL statements (which are defined during runtime) to connect to the MySQL database...
Can anyone help me with this?
Thanx in advance..
;p
Last edited by superfrog80; Sep 30th, 2003 at 04:10 AM.
-
Sep 26th, 2003, 06:31 AM
#2
Fanatic Member
Add a DataReport to your project (Project->Add Data Report). Add label's for your captions/headers and TextBoxes for your data fields. Set the DataField property for each TextBox to it's corresponding field from the database.
In the DataReport_Initialize method, create a recordset containing the information you wish to return from the database and set the datasource of the report to the recordset:
VB Code:
Private Sub DataReport_Initialize()
On Error GoTo errHandler
Dim sSql As String
Dim sConStr As String
Dim oCon As Connection
Dim oRS As Recordset
sConStr = "Your Connection String"
'Define your query
sSql = "Select * From MYTABLE"
Set oConn = New Connection
With oConn
.CursorLocation = adUseClient
.CommandTimeout = 10
.Open sConStr
End With
Set oRS = New Recordset
oRS.Open sSQL, oConn, adOpenStatic, adLockReadOnly
If Not oRS.BOF And Not oRS.EOF Then
Set Me.Datasource = oRS
Else
MsgBox "No Records Found.", vbExclamation + vbOKOnly, "Invalid Recordset"
oRS.Close
Set oRS = Nothing
bOpen = False
oConn.Close
Set oConn = Nothing
Unload Me
End If
Exit Sub
errHandler:
Msgbox err.number & vbcrlf & vbcrlf & err.description
End Sub
Chris
Master Of My Domain
Got A Question? Look Here First
-
Sep 30th, 2003, 04:09 AM
#3
Thread Starter
Member
thanx man!!...
jez wat i needed!!
;p
-
Sep 30th, 2003, 04:17 AM
#4
Hey, you're a frog too.
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
|