C# WPF 连接SQL Server2008问题
在SQL Server里建立一个名字为"MyTest”数据库,在VS2010里
代码如下:
private void btnTestADO_Click(object sender, RoutedEventArgs e)
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=MyTest;User ID=sa;Password=fengsj0113410258"))
{
try
{
conn.Open();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
MessageBox.Show("Executing Finished");
}