PDA

Click to See Complete Forum and Search --> : [RESOLVED] [2.0] get the connection string


shakti5385
Feb 16th, 2007, 12:00 AM
Hi all :wave:
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
Public Property ConnectionStringName() As String
Get
Return _ConnectionStringName
End Get
Set(ByVal value As String)
If value Is Nothing Or value = "" Then
Throw New Exception("Can not set null value in Connection String!!!")
End If
_ConnectionStringName = value
_ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings(value).ConnectionString
End Set

End Property

Harsh Gupta
Feb 16th, 2007, 12:36 AM
public string ConnectionStringName
{
get
{
return _ConnectionStringName;
}

set
{
if (value == null || value == "")
{
throw new Exception("Can not set null value in Connection String!!!");
}
_ConnectionStringName = value;
_ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings(value).ConnectionString;
}
}

shakti5385
Feb 16th, 2007, 01:26 AM
Thanks for reply :wave:
_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 :confused:

Harsh Gupta
Feb 16th, 2007, 12:28 PM
Sorry my mistake, it should be [] instead of ()
_ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings[value].ConnectionString;

shakti5385
Feb 16th, 2007, 11:52 PM
THANKS