Results 1 to 8 of 8

Thread: [2005] in dll project:I need my dataset to read the connectionstring from web.config

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    589

    [2005] in dll project:I need my dataset to read the connectionstring from web.config

    Hi,

    I created a dll that serves as my data logic and a bit of business logic

    in the dll, I used dataset designer to generate my data access classes...etc

    Because it s a dll project, the dataset reads the connection string from the file: Settings.settings

    Need: For maintainance reasons, I dont want my dataset to get the connectionstring from the dll file Settings.settings but from the file web.config of the main web application. I need to do that overwriting the designer.cs when the DB changes or when the dataset is regenerated again.
    Thanks a lot for your help.

  2. #2
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: [2005] in dll project:I need my dataset to read the connectionstring from web.config

    So, what's the real question?

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    589

    Re: [2005] in dll project:I need my dataset to read the connectionstring from web.config

    the real question is: in the dataset of the dll, I need to set its connectionstring from the web.config of the main web application. this last web application refers to the dll including the dataset

    thnx
    Thanks a lot for your help.

  4. #4
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: [2005] in dll project:I need my dataset to read the connectionstring from web.config

    In that case you'd have to edit the code file that created the dll. Tell it to look at the web.config instead of itself.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    589

    Re: [2005] in dll project:I need my dataset to read the connectionstring from web.config

    how do i do that?
    notice it s a dll project
    thnx
    Thanks a lot for your help.

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] in dll project:I need my dataset to read the connectionstring from web.config

    It's a DLL project, so why are you using a designer?

    If you're still going to continue like this, search for a place in your generated code where the settings file is being referenced. You can then modify it to use System.Configuration.ConfigurationSettings... but if you can't find it, then it's time for you to re-think your DLL.

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    589

    Re: [2005] in dll project:I need my dataset to read the connectionstring from web.config

    Quote Originally Posted by mendhak
    It's a DLL project, so why are you using a designer?
    .
    Because I want the designer to generate all the classes I need automatically, I don t want to code all the data classes, objects classes...etc,
    do i have any other choice, Mr Mendhak?

    Quote Originally Posted by mendhak
    If you're still going to continue like this, search for a place in your generated code where the settings file is being referenced. You can then modify it to use System.Configuration.ConfigurationSettings... but if you can't find it, then it's time for you to re-think your DLL.
    If I do it that way, Is not that code gonna be overiden when the dataset is regenerated next time, let s say if I change some thing in my dataadapters or if I add a field in a datatable in my dataset?

    Here is the place where setting file is referenced, it s in the designer.cs file of my dataset like this:

    private void InitConnection() {
    this._connection = new System.Data.SqlClient.SqlConnection();
    this._connection.ConnectionString = global::EticketsDAL.Properties.Settings.Default.OrleansEcommConnectionString;


    If I change that, won't the changes I make be overriden next time I regenerate the dataset?



    Thanks a lot
    Last edited by tutus; Aug 3rd, 2007 at 09:00 AM.
    Thanks a lot for your help.

  8. #8
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] in dll project:I need my dataset to read the connectionstring from web.con

    Quote Originally Posted by tutus
    Because I want the designer to generate all the classes I need automatically, I don t want to code all the data classes, objects classes...etc,
    do i have any other choice, Mr Mendhak?
    Yes. Coding all the data classes and objects as required. Some may call it convenience, I call it laziness.


    If I do it that way, Is not that code gonna be overiden when the dataset is regenerated next time, let s say if I change some thing in my dataadapters or if I add a field in a datatable in my dataset?

    Here is the place where setting file is referenced, it s in the designer.cs file of my dataset like this:

    private void InitConnection() {
    this._connection = new System.Data.SqlClient.SqlConnection();
    this._connection.ConnectionString = global::EticketsDAL.Properties.Settings.Default.OrleansEcommConnectionString;


    If I change that, won't the changes I make be overriden next time I regenerate the dataset?

    Thanks a lot
    Suit yourself. http://www.bbits.co.uk/blog/archive/...1/28/6698.aspx

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width