Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi.. Friends I have a window based project in vb.net and SQL 2005 my requirement is that I want to make it fully dynamically means, when first user use it he set the sql server name or password for the application only first time. After that if sql server name has been changed then it ask again to the user who first of all use the application after change the server name or password. Please help how can i get it.

Thanks in advance

Parveen Rathi
Posted
Updated 21-Nov-11 2:47am
v2

1 solution

If you have change notification function then it must be easy to implement, or else possibly if log in fails you can prompt for the credentials again.

Just persist the value on Registry or as a file, and make use of it each time a login is required, and when it fails on a try just prompt for it and over write the persisted values.

this is just a way of doing it, modify it as needed and have fun.

C#
private void LogTheUserIn()
{
    /*
     * that includes uid, pwd, possibly connection string
     * here i proceed with the persisted values
     * not prompting from the user.
     */
    string credentials = GetPersistedCredentials();

    bool loginFailed = TryConnectToServer(credentials);

    /* there are many possibilities it may fail, I assume its coz of credentials */
    if (loginFailed)
    {
        credentials = PromptForCredentials();
        OverWritePersistedCredentials(credentials);

        /*
         * log in with the new credentials.
         * Be sure to avoid recursion.
         */
        LogTheUserIn();
    }
}



Hope it helps.
 
Share this answer
 
v2
Comments
Parveen Rathi 21-Nov-11 9:50am    
Will u please explain or give any example
VallarasuS 21-Nov-11 10:15am    
Check the updated solution. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900