开发者

How to make up for changed Sql Server database password

There is a website made using .net, the maker has gone and we can't find him.

For a long time we don't know the password of the sql server database, today I tried to reset the password and then found the website can't connect to the database!

However I've got the .cs and .aspx and .dll files, I checked the code and find it getting connection in the following way:

    public string ConnectString
{
    get
    {
        if (this.connectString == string.Empty)
        {
            System.Configuration.AppSettingsReade开发者_高级运维r Reader = new AppSettingsReader();
            connectString = (string)Reader.GetValue("conn", System.Type.GetType("System.String"));
        }
        return connectString;
    }
    set
    {
        connectString = value;
    }
}

public SqlConnection SqlConnection
{
    get
    {
        if (SqlCn == null)
        {
           SqlCn = new SqlConnection(ConnectString);

        }
        return SqlCn;
    }
}

Since I've only known some JDBC and never touched .net, i've no ider how this works:

System.Configuration.AppSettingsReader Reader = new AppSettingsReader();
 connectString = (string)Reader.GetValue("conn", System.Type.GetType("System.String"));

Can I find the connectString in some file so I can change the password back? I searched all the files I have and can't find any containing the keyword "pwd" or "database" is useful. Now I have a new database password, can I simply change the line:

SqlCn = new SqlConnection("server=127.0.0.1;database=****;uid=sa;pwd=****");

Still I want to know how to recompile the .cs to .aspx, and what I need to know to recover the website?


Look for the configuration file. App.config is my guess.


Find the webapp's web.config file, and look to the <appSettings> section, <conn> property.


from what you are asking, you definitely are not a techie. you would have to look at your web.config (as you have mentioned aspx) for "Initial Catalog" under "conn" key in <appSettings> section. Your server cannot be 127.0.0.1 unless you are running your web server (IIS) and your SQL Server from the same machine. I would suggest you hire someone who has some programming experience if you are looking for a long term solution including maintenance of your application

Edit:If you do have access to your SQL Server/if you have a DBA, you can reset the password for this user and use the new password. Rather than using SQL Authentication (username/password), I would suggest you to use Windows authentication as it is more secure

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜