Click here to Skip to main content
15,886,761 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hey All,

I'm trying to use ReportMax for reporting in my app, but I can't figure out how to change the connection string (or data source) for my report at run-time.

I found this link on their forum: http://www.cppmax.com/forum/forum_posts.asp?TID=43&PID=132&title=how-to-pass-dataset-to-report#132

...but I'm not advanced enough to really understand what to do w/ that.

All I really want to do is pass it the path to my database at runtime. I tried just doing a string replace in the report file, but I somehow corrupted the file and it wouldn't load. Ughhh.

Any takers?

Thanks,
Bret
Posted
Updated 18-Mar-16 21:40pm
v2

OK. I figured it out. The code I was using to replace the connection string in the report file was wrong. Once I fixed that it's working fine.

I can't find much out there on using ReportMax, so just in case someone else is wondering about this, here's the scoop.

Before running a report, if I want to query from a different database (or change the SQL for a report for that matter), I just call this sub with the report file, the target string, and the replacement string.
VB
Private Sub ReplaceTextInFile(WhichFile As String, WhichTarget As String, WhichReplacementText As String)
    Dim MyText As String = File.ReadAllText(WhichFile)
    MyText = Replace(MyText, WhichTarget, WhichReplacementText)
    System.IO.File.Delete(WhichFile)
    File.WriteAllText(WhichFile, MyText)
End Sub


I call it like this:

VB
ReplaceTextInFile("C:\Users\Daddio68\Desktop\ReportMax1.rpm", "C:\Users\Daddio68\Desktop\DBOld.mdb", "C:\Users\Daddio68\Desktop\DBNew.mdb")
frmReportTest.ShowDialog()
 
Share this answer
 
Try this:

Paste it in Properties > Connection String (of .rpm file)

C#
Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=C:\Users\Pc 1\Desktop\YOUR_DATABASE.mdb;Mode=Share Deny None;Extended Properties='';Jet OLEDB:System database='';Jet OLEDB:Registry Path='';Jet OLEDB:Database Password='';Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password='';Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False


Copy all including the violet one :) then change the path(Data Source) where your database is located

Then enter your SQL Statement in Properties > SQL

Have fields(Textbox) in the report then change their DataField on whatever DataField you want. Hope it works.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900