ReportMax - 如何在运行时更改连接字符串(数据源)? [英] ReportMax - How do I change the connection string (data source) at runtime?

查看:120
本文介绍了ReportMax - 如何在运行时更改连接字符串(数据源)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿所有,



我正在尝试使用ReportMax在我的应用中报告,但我无法弄清楚如何更改连接字符串(或数据源)我在运行时的报告。



我在他们的论坛上找到了这个链接: http://www.cppmax.com/forum/forum_posts.asp?TID=43& ; PID = 132& title =如何通过数据集到报告#132



......但我还不够先进要真正理解该做什么。



我真正想做的就是在运行时将它传递给我的数据库。我试过在报告文件中做一个字符串替换,但我以某种方式损坏了文件,它不会加载。 Ughhh。



任何接受者?



谢谢,

布雷特

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

推荐答案

好的。我想到了。我用来替换报告文件中的连接字符串的代码是错误的。一旦我确定它工作正常。



我在使用ReportMax时找不到多少,所以万一有人想知道这个,这就是勺子。



在运行报告之前,如果我想从另一个数据库进行查询(或者为此报告更改SQL报告),我只需要调用此子报表报告文件,目标字符串和替换字符串。

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.
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:

ReplaceTextInFile("C:\Users\Daddio68\Desktop\ReportMax1.rpm", "C:\Users\Daddio68\Desktop\DBOld.mdb", "C:\Users\Daddio68\Desktop\DBNew.mdb")
frmReportTest.ShowDialog()


试试这个:



将其粘贴到属性>连接字符串(.rpm文件)



Try this:

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

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





复制包括紫罗兰色的所有内容:)然后更改数据库所在的路径(数据源)



然后在属性中输入您的SQL语句> SQL



报表中的字段(文本框)然后在您想要的任何DataField上更改其DataField。希望它有效。



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.


这篇关于ReportMax - 如何在运行时更改连接字符串(数据源)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆