|
-
Jan 30th, 2006, 02:02 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] recordset result on crystal
Hi RobDog888,
please help me!!!
your code is working fine.
but my problem is..
i am not getting the select * from table query values on crystal.
i was already created the report newreport.rpt.it is a blank report.
and i want the query result when i press command9 button.
nearly from 3 weeks i working on this report
please give me some solution
VB Code:
Private Sub Command9_Click()
Dim oreport As CRAXDRT.report
Dim oapp As CRAXDRT.Application
Dim oRs As Recordset
Dim sSQL As String
Set oRs = New Recordset
Set oRs = db_conn.Execute("SELECT * FROM table")
Set oapp = New CRAXDRT.Application
Set oreport = oapp.OpenReport(App.Path & "\newreport.rpt", 1)
oreport.Database.SetDataSource oRs, 3, 1
CRViewer91.ReportSource = oreport
CRViewer91.ViewReport
End sub
thank u
Last edited by RobDog888; Jan 30th, 2006 at 02:06 PM.
Reason: Added [vbcode] tags
-
Jan 30th, 2006, 02:07 PM
#2
Re: recordset result on crystal
Ok, you say you created the report in CR but did you use the same fields from Table when you bound the textboxes to the fields?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 30th, 2006, 02:19 PM
#3
Thread Starter
Hyperactive Member
Re: recordset result on crystal
hi robdog888,
thanks for your reply.
really i don't know how to get the values to report.
i created a blankreport just adding one table to data expert in crystal report.
i haven't added any fields to report .it is completely blank.
could you please advice me how to create the report,and get the values from sql query to crystal report.
thanks
wizkid
-
Jan 30th, 2006, 02:29 PM
#4
Re: recordset result on crystal
Moved to reporting section
-
Jan 30th, 2006, 02:42 PM
#5
Re: recordset result on crystal
Oh, thats why. You need to open the field explorer and drag the field you want on your report to the actual report. If you dont add any fields to the report page then your report wil be blank.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 30th, 2006, 03:05 PM
#6
Thread Starter
Hyperactive Member
Re: recordset result on crystal
Hi, thanks for ur suggestion but the thing is i am not asking for the crystal report designing, i know crystal reports designing but what i wanted to do is, i wanted to run some queries and get those results on the report, i am doing some calculations for the style_code and all, so we need to show them calculations and figures on the report.
i have one more doubt,on ur code you have given as
VB Code:
Set oRs = New Recordset
Set oRs = db_conn.Execute("SELECT * FROM table")
Set oapp = New CRAXDRT.Application
Set oreport = oapp.OpenReport(App.Path & "\newreport.rpt", 1)
[COLOR=RoyalBlue]oreport.Database.SetDataSource oRs, 3, 1[/COLOR]
CRViewer91.ReportSource = oreport
CRViewer91.ViewReport
End sub
i wanted to know, what will the blue colour line code do there ?
thank you,
wizkid.
-
Jan 30th, 2006, 03:12 PM
#7
Re: recordset result on crystal
It binds the ADO recordset resultset to the report but it will only show data if you have the corresponding fields bound to controls on the report. You can use a generic sql statement that brings in the desired fields in CR. Then all you need to do is modify the sql query to perform any calculations, etc.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 30th, 2006, 03:19 PM
#8
Thread Starter
Hyperactive Member
Re: recordset result on crystal
Hi RobDog888,
thanks for your reply.
ok fine.
for example i want to get the result..like select * from employee where staffid=123 into the report.
1.to get the result how should i design the report and
2.which code should i write in vb
please give me steps
thanks a lot
wizkid
-
Jan 30th, 2006, 03:56 PM
#9
Re: recordset result on crystal
Ok, in CR set your database location and create an ADO connection to it. Then select the Employees table as your source table. Once you have that part you can add the fields to your details section. Make sure you have "Save data with report" unchecked in the report properties.
next in VB do like my code example but the ADO connectionstring will be pointing to the database location. It should either be relative if its a local db or an UNC path to the server\share it resides. Then when you .Open your recordset, pass the new sql statement like you posted. The the rest is the same.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 30th, 2006, 05:29 PM
#10
Thread Starter
Hyperactive Member
Re: recordset result on crystal
Hi RobDog888,
Thanks a lot for your suggestions.
i followed all your instructions.
VB Code:
Dim db_conn As New ADODB.Connection
Dim rs As ADODB.Recordset
Private Sub Form_Load()
Dim CRReport As CRAXDRT.Report
Dim CRApp As New CRAXDRT.Application
'Open the Crystal Report
Set CRReport = CRApp.OpenReport("C:\Program Files\Microsoft Visual Studio\VB98\newreport\Report2.rpt")
Set rs = New ADODB.Recordset
db_conn.Open "Driver={Microsoft ODBC for Oracle};" & _
"Server=TEST;" & _
"Uid=scott;" & _
"Pwd=tiger"
Dim sqlq As String
sqlq = "Select * from Employee where EmpID = 1"
With CRReport
.Database.Tables(1).Location = App.Path & "\MagData"
rs.Open sqlq, db_conn, adOpenStatic, adLockReadOnly
End With
End Sub
MagData is our oracle database
rs.Open sqlq, db_conn, adOpenStatic, adLockReadOnly -------after this statement how can i proceed? i want to show the report in CrystalActiveXReportViewer
thank you
wizkid
-
Jan 30th, 2006, 06:00 PM
#11
Thread Starter
Hyperactive Member
Re: recordset result on crystal
Hi RobDog888,
Thank you very much for your help.
thanks a lot.
i got it.
it is working fine
VB Code:
Dim db_conn As New ADODB.Connection
Dim rs As ADODB.Recordset
Private Sub Form_Load()
Dim CRReport As CRAXDRT.Report
Dim CRApp As New CRAXDRT.Application
'Open the Crystal Report
Set CRReport = CRApp.OpenReport("C:\Program Files\Microsoft Visual Studio\VB98\newreport\Report2.rpt")
Set rs = New ADODB.Recordset
db_conn.Open "Driver={Microsoft ODBC for Oracle};" & _
"Server=Test;" & _
"Uid=Scott;" & _
"Pwd=tiger"
Dim sqlq As String
sqlq = "Select empid from employee where empid like 'M4%'"
With CRReport
'Set the Access database path
.Database.Tables(1).Location = App.Path & "\MaData"
rs.Open sqlq, db_conn, adOpenStatic, adLockReadOnly
.Database.SetDataSource rs, 3, 1
CrystalActiveXReportViewer1.ReportSource = CRReport
CrystalActiveXReportViewer1.ViewReport
End With
End Sub
if i get any problem i will ask you.
once again thank you
wizkid
Last edited by wizkid; Jan 31st, 2006 at 04:41 AM.
-
Jan 31st, 2006, 02:10 AM
#12
Re: recordset result on crystal
Glad its finally working for you now. 
Ps, dont forget to 'Resolve' your thread so others will know its solved.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
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
|