Re: Maintaining and Using App Login details
From: Sijin Joseph (sijinNOSPAMdotnet_at_hotmail.com)
Date: 09/26/04
- Next message: Sijin Joseph: "Re: ComboBox Row Source = Result of DB Query?"
- Previous message: Sijin Joseph: "Re: detecting print preview"
- In reply to: Craig - A Healtchare IT developer: "Maintaining and Using App Login details"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 26 Sep 2004 20:05:57 +0530
I define the connection string in either the application config file
(app.config) or the registry and then use a class which exposes a static
method that returns the connection string.
For e.g.
public class Settings
{
public static ConnectionString
{
get
{
//Get the connection string either by using registry or by using
ConfigurationSettings.AppSettings class
}
}
}
Now in all the classes where i need a connection i simply use
SqlConnection conn = new SqlConnection(Settings.ConnectionString);
Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
Craig - A Healtchare IT developer wrote:
> Hi,
>
> I'm developing an Windows forms based app that will draw data from a SQL
> Server 2000 system, that is set to use SQL Authentication (i.e. connection
> string must pass uname:pword).
>
> Given that various forms will need to use a SQL connection to generate data
> for data grid's etc ... how can I pass this authentication information around
> the various forms?
>
> A solution is to start the application from a VB.NET class, that has a
> shared member with the connection string (set once the user completes the
> login)
>
> Or create a shared connection object? Should I create a new connection
> object for each form?
>
> I currently test whether the login credentials are correct by enclosing
> within a try..catch clause an attempt to open and close a connection, failure
> will indicate invalid details (or perhaps a dead SQL Server!) ... any
> improvements on this?
>
> I assume that when using the form designer in VS.NET that if I manually
> program the connection (i.e. outside the section of code written by VS.NET )
> that I can point the adapters/datasets etc. to the required connection.
>
> There are a few questions here ... but I've not so far found any answers
> here, on Google or elsewhere :( !
>
> Thanks in advance for help
>
>
- Next message: Sijin Joseph: "Re: ComboBox Row Source = Result of DB Query?"
- Previous message: Sijin Joseph: "Re: detecting print preview"
- In reply to: Craig - A Healtchare IT developer: "Maintaining and Using App Login details"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|