Passing Connectionstring as parameter in SSRS through URL

拜拜、爱过 提交于 2019-12-25 02:37:30

问题


I am working on an application using Classic ASP and SQL Server 2008 R2. We are using SSRS for the reports. Now the datasource changes depending on the user. I have been using a parameter for the connectionstring. It is working fine but the problem is the connectionstring shows in the URL. Is there a way to hide it? Or is there a better way. Please Help.


回答1:


Yes - change the method on your form to POST and use the Request.Form syntax instead of Request.QueryString:

<form id="myForm" method="post" action="myPage.asp">
    <label for="txtBox">Type something</label>
    <input type="text" id="txtBox" name="txtBox" />
</form>
<%
Dim value
value = Cstr(Request.Form("txtBox"))
If value <> "" then
    'Do your processing
End if
%>

-- EDIT --

To be honest, though, I would not store my connection string on my form like this. You'd be far better off storing it in an Application level variable, like so:

Application("CON_STRING") = "...blahblahblah..."

This should be stored in the Application_OnStart event of the Global.asa* file.

* Apologies for the link to w3schools - it was the best at the time!

-- EDIT 2 --

Try using an iframe to display the info...

<form id="frmRender" action="ABCD/ReportServer?/Reports/rptSalesReport.rpt"; method="post" target="_blank">
    <input type="hidden" name="rs:Command" value="Render">
    <input type="hidden" name="rc:LinkTarget" value="_blank">
    <input type="hidden" name="rs:Format" value="HTML4.0">
    <input type="hidden" name="rc:Parameters" value="False">
    <input type="hidden" name="ConnectionString" value="<%=Session("ConnectionString")%>">
    <input type="hidden" name="StartDate" value="<%=StartDate%>">
    <input type="hidden" name="EndDate" value="<%=EndDate%>">
    <a id="linkInfo" href="javascript:generateSsrs();">Generate Report</a>

    <iframe id="ssrsReport" class="reportHeightWidth"></iframe>
</form >

<script language="javascript">
    function genreateSsrs() {
        document.getElementById("ssrsReport").src = "ABCD/ReportServer?/Reports/rptSalesReport.rpt?rs:Command=Render&rc:LinkTarget=top&rs:Format=HTML4.0&rc:Parameters=False&ConnectionString=<%=Server.URLEncode(Session("ConnectionString"))%>&StartDate=<%=StartDate%>&EndDate=<%=EndDate%>";
    }
</script>

That's a rough version, but it's untested, so may need some tweaks.




回答2:


In you code, use the below code

 ="Data Source="+Parameters!DatabaseServerName.Value+";Initial Catalog="&Parameters!DatabaseCatalogName.Value


来源:https://stackoverflow.com/questions/25864031/passing-connectionstring-as-parameter-in-ssrs-through-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!