连接本地sql失败,提示:executenonquery 要求已打开且可用,当前为关闭
代码如下,刚接触这个,很多不懂的,下面的代码都放在一个事件里的,求指导SqlConnectionStringBuilderscsb=newSqlConnectionStr...
代码如下,刚接触这个,很多不懂的,下面的代码都放在一个事件里的,求指导
SqlConnectionStringBuilder scsb = new SqlConnectionStringBuilder();
scsb.DataSource = @"(local)\SQLExpress";
scsb.IntegratedSecurity = true;
scsb.InitialCatalog = "Picture";
myConnection = new SqlConnection(scsb.ConnectionString);
SqlCommand com = myConnection .CreateCommand();
com.CommandText = "Update 表 Set [图片]=@F Where ID='0001'";
com.CommandType = CommandType.Text;
SqlParameter sp = new SqlParameter("@F", SqlDbType.Image, bFile.Length, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, bFile);
com.Parameters.Add(sp);
com.ExecuteNonQuery();
myConnection.Close(); 展开
SqlConnectionStringBuilder scsb = new SqlConnectionStringBuilder();
scsb.DataSource = @"(local)\SQLExpress";
scsb.IntegratedSecurity = true;
scsb.InitialCatalog = "Picture";
myConnection = new SqlConnection(scsb.ConnectionString);
SqlCommand com = myConnection .CreateCommand();
com.CommandText = "Update 表 Set [图片]=@F Where ID='0001'";
com.CommandType = CommandType.Text;
SqlParameter sp = new SqlParameter("@F", SqlDbType.Image, bFile.Length, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, bFile);
com.Parameters.Add(sp);
com.ExecuteNonQuery();
myConnection.Close(); 展开
若以下回答无法解决问题,邀请你更新回答
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询