ExecuteNonQuery 要求已打开且可用的连接。连接的当前状态为已关闭 10
stringstrS="insert个(歌曲)values('"+TextBox2.Text+"')";SqlCommandcmd=newSqlCommand();cmd...
string strS = "insert 个(歌曲)values('" + TextBox2.Text + "')";
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = strS;
//SqlDataAdapter da = new SqlDataAdapter(strS,conn );
//DataSet ds = new DataSet();
//da.Fill(ds, "t1");
//GridView1.DataSource = ds.Tables["t1"].DefaultView;
cmd.ExecuteNonQuery();
conn.Close();
GridView1.DataBind(); 展开
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = strS;
//SqlDataAdapter da = new SqlDataAdapter(strS,conn );
//DataSet ds = new DataSet();
//da.Fill(ds, "t1");
//GridView1.DataSource = ds.Tables["t1"].DefaultView;
cmd.ExecuteNonQuery();
conn.Close();
GridView1.DataBind(); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询