询问sql server的名称和密码,再询问是否更改 [英] Ask for sql server name and password, ask again if changed

查看:59
本文介绍了询问sql server的名称和密码,再询问是否更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..朋友我在vb.net和SQL 2005中有一个基于窗口的项目,我的要求是我想使其完全动态地实现,即当第一个用户使用它时,他仅为应用程序设置sql服务器名称或密码.第一次.此后,如果更改了sql服务器名称,则它会再次询问用户,该用户在更改服务器名称或密码后首先使用该应用程序.请帮助我如何获取它.

在此先感谢

Parveen Rathi

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

推荐答案

如果您具有更改通知功能,则必须易于实现,否则,如果登录失败,则可以再次提示输入凭据. />
只需将值保留在Registry上或作为文件保留,并在每次需要登录时都使用它,当尝试登录失败时,只需提示输入并覆盖保留的值即可.

这只是一种方法,可以根据需要对其进行修改并从中获得乐趣.

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.

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.


这篇关于询问sql server的名称和密码,再询问是否更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆