在C#中的数据库连接字符串问题: private void button1_Click(object sender, EventArgs e)
{
con = new SqlConnection();
string q = "Data Source=TOSHIBA-PC;Initial Catalog=ACCESSCONTROL;User ID=ABC;Password=hello;MultipleActiveResultSets=True";
cmd = new SqlCommand (q,con);
try
{
con.Open();
MessageBox.Show("Connection opened.");
}
catch (SyntaxErrorException a)
{
MessageBox.Show("Error: " + a);
}
finally
{
con.Close();
MessageBox.Show("Connection closed.");
}
}
错误:ConnectionString属性尚未初始化。