Maintaining and Using App Login details

G

Guest

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
 
G

Guest

Hi

You can use the Data Application Block of Microsoft for connecting to a SQL
Server database and executing the commands in it. This is coming under MS
patterns & practices.

The SQLHelper class of the Assembly having lots of members to achieve this.

You can define the connection string in the Application Configuration File.
(App.Config)

For more reference on MS Data Application Block visit
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/daab-rm.asp

Regards
Sooraj
 
S

Sijin Joseph

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top