Results 1 to 5 of 5

Thread: [RESOLVED] [2.0] get the connection string

  1. #1

    Thread Starter
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Resolved [RESOLVED] [2.0] get the connection string

    Hi all
    I want to get the connection string from the config file
    but i am confused here
    I make a code in the VB.NET but what about the c#
    See my code in the VB.NET

    VB Code:
    1. Public Property ConnectionStringName() As String
    2.         Get
    3.             Return _ConnectionStringName
    4.         End Get
    5.         Set(ByVal value As String)
    6.             If value Is Nothing Or value = "" Then
    7.                 Throw New Exception("Can not set null value in Connection String!!!")
    8.             End If
    9.             _ConnectionStringName = value
    10.             _ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings(value).ConnectionString
    11.                   End Set
    12.  
    13.     End Property

  2. #2
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: [2.0] get the connection string

    VB Code:
    1. public string ConnectionStringName
    2. {
    3.     get
    4.     {
    5.         return _ConnectionStringName;
    6.     }
    7.  
    8.     set
    9.     {
    10.         if (value == null || value == "")
    11.         {
    12.             throw new Exception("Can not set null value in Connection String!!!");
    13.         }
    14.         _ConnectionStringName = value;
    15.         _ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings(value).ConnectionString;
    16.     }
    17. }
    Show Appreciation. Rate Posts.

  3. #3

    Thread Starter
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up Re: [2.0] get the connection string

    Thanks for reply
    Code:
    _ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings(value).ConnectionString;
    this i try
    But the main question is that why connectionstring property is not appearing after pressing dot here
    _ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings(value).??

    why connection string property is not appearing

  4. #4
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: [2.0] get the connection string

    Sorry my mistake, it should be [] instead of ()
    VB Code:
    1. _ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings[B][[/B]value[B]][/B].ConnectionString;
    Show Appreciation. Rate Posts.

  5. #5

    Thread Starter
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: [2.0] get the connection string

    THANKS

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