当前上下文中不存在名称ConnectionState是怎么回事啊
try{SqlConnectionconn=newSqlConnection();conn.ConnectionString="DataSource=.;InitialC...
try
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Data Source=.;Initial Catalog=Login;Integrated Security=True";
if (conn.State == ConnectionState.Open)
{
conn.Open();
string sql2 = "insert into textinformation (课程名称,主题,英文名称,适用范围,学分,总学时,理论学时,课程作用与目的,课程基本要求) values ('" + textBox1.Text.Trim() + "','" + textBox2.Text.Trim() + "', '" + textBox3.Text.Trim() + "','" + textBox4.Text.Trim() + "','" + textBox5.Text.Trim() + "','" + textBox6.Text.Trim() + "','" + textBox7.Text.Trim() + "','" + richTextBox1.Text.Trim() + "','" + richTextBox2.Text.Trim() + "')";
}
catch (Exception ex)
{
MessageBox.Show("数据库连接失败" + ex.Message);
} 展开
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Data Source=.;Initial Catalog=Login;Integrated Security=True";
if (conn.State == ConnectionState.Open)
{
conn.Open();
string sql2 = "insert into textinformation (课程名称,主题,英文名称,适用范围,学分,总学时,理论学时,课程作用与目的,课程基本要求) values ('" + textBox1.Text.Trim() + "','" + textBox2.Text.Trim() + "', '" + textBox3.Text.Trim() + "','" + textBox4.Text.Trim() + "','" + textBox5.Text.Trim() + "','" + textBox6.Text.Trim() + "','" + textBox7.Text.Trim() + "','" + richTextBox1.Text.Trim() + "','" + richTextBox2.Text.Trim() + "')";
}
catch (Exception ex)
{
MessageBox.Show("数据库连接失败" + ex.Message);
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询