我正在開發窗口應用程序,我希望應用程序的用戶可以更改連接字符串,所以我創建一個表單來保存連接字符串設置並能夠檢索它,但問題是如何使用這個設置如何使用檢索和使用設置值連接到adatabase
private void button1_Click(object sender, EventArgs e)
{
var serv = Properties.Settings.Default.server;
var db = Properties.Settings.Default.database;
var userid = Properties.Settings.Default.userid;
var pass = Properties.Settings.Default.password;
SqlConnection conn = new SqlConnection("Data Source=serv;Initial Catalog=db;User ID=userid password=pass");
SqlDataAdapter sda = new SqlDataAdapter("SELECT count(*) FROM users WHERE username='" + txtUsername.Text + "' and password='" + txtPassword.Text + "'", conn);
}