Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / September 2004

Tip: Looking for answers? Try searching our database.

Maintaining and Using App Login details

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Craig - A Healtchare IT developer - 25 Sep 2004 12:57 GMT
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
Sooraj PM - 26 Sep 2004 11:27 GMT
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

> Hi,
>
[quoted text clipped - 26 lines]
>
> Thanks in advance for help
Sijin Joseph - 26 Sep 2004 15:35 GMT
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

> Hi,
>
[quoted text clipped - 26 lines]
>
> Thanks in advance for help

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.