accessing report server programmatically

Hi friends
I have .net app ,where i display reports from my report server in a screen .,which works fine.
I added a web reference to my report server ,to my solution to get it work.

since i know my report server name on machine i added webreference to my project. but when i deploy at site ,as you can guess, the server name can be different.

is it possible add web reference programmaically so that i dont need to hard code report server name

am using sql server standard 2005,VS2005 standard edition.
Thank you very much for your help




Answer this question

accessing report server programmatically

  • maclessi

    Alexandre
    if i understood you correctly, i just need to add a web reference to one of in-house report servers ,to our solution but when using it at client sites i need update "URL" property of the  web service object by reading either from a config file or from a database field.
    is this correct
    Thanks for your help


  • PIEBALD

    You can use the following in your web.config:

    <appSettings>
    <add key="ServerURL" value=http://someServer/path/method.aspx />

    </appSettings>

    And in your code:


    reportService.Url = ConfigurationSettings.AppSettings["ServerURL"];


  • panagorafredrik

    Alexandre
    Thanks for the post.
    do you happen to know any sample code i can refer to.
    Thanks for your help again.


  • Stephen Hauck

    try web.config file... i think u got it... define it in web.config file and change it whenever the server name changes

  • NicksterFL

    in the place where you instantiate the webservice client:

    MyReportServer rs = new MyReportServer();
    rs.Url = "http://myservername/reportserver/blabla.asmx";



  • Pete Loveall

    Hi Jay
    its a windows app and i dont have a web.config.


  • Martin McNally

    When you add a web reference VS will add a C# file to your project with web service endpoint definition. Then in some place in your program you make a call to the web service. the web service will be represented by an object. I refered to the type of the object MyReportServer, mostlikely it will be called differently in your app. This object has Url property that you may assign any new report server URL you want. Just find the place where the object is created.

    By default, "MyReportServer" class pulls webservice URL from your config file. You can reset it by assigning new url via Url property



  • rpesq

    Thanks Alexandre
    i already tried and it works nicely.
    Thank you very much for your help :)


  • VBnerd

    Alexandre
    i cant find "MyReportServer" namespace!
    what library i need to give reference to
    Thanks for your help


  • Abu S. Md. Ismail

    >> if i understood you correctly

    yes.



  • accessing report server programmatically