ExecuteNonQuery: Connection 属性尚未初始化
try{System.Data.SqlClient.SqlDataReaderreader=null;System.Data.SqlClient.SqlCommandco...
try
{
System.Data.SqlClient.SqlDataReader reader = null;
System.Data.SqlClient.SqlCommand comd1 = new SqlCommand(sql, Conn);
comd1.Transaction = this.Trans;
reader = comd1.ExecuteReader();
while (reader.Read())
{
returnObj = reader[0];
}
reader.Close(); reader = null;
comd1.Dispose(); comd1 = null;
}
catch (Exception ex)
{
if (this.IsOnline && this._IsDrop)
{
this._IsDrop = false;
return GetValueBySQL(sql);
}
else
{
this._IsDrop = false;
System.Console.WriteLine(ex.Message);
throw ex;
}
}
if (returnObj == null) returnObj = "";
return returnObj;
}
public object GetValueBySQL(string sql, System.Data.SqlClient.SqlConnection conn)
{
object returnObj = null;
// System.Data.DataTable dt=this.GetDataTable(sql);
// if(dt.DefaultView.Count>0)
// {
// returnObj=dt.DefaultView[0][0];
// }
//
// dt.Dispose();dt=null;
// if(returnObj==null) returnObj="";
// return returnObj;
try
{
System.Data.SqlClient.SqlDataReader reader = null;
System.Data.SqlClient.SqlCommand comd1 = new SqlCommand(sql, conn);
comd1.Transaction = this.Trans;
reader = comd1.ExecuteReader();
while (reader.Read())
{
returnObj = reader[0];
}
reader.Close(); reader = null;
comd1.Dispose(); comd1 = null;
}
catch (Exception ex)
{
System.Console.WriteLine(ex.Message);
throw ex;
}
if (returnObj == null) returnObj = "";
return returnObj;
} 展开
{
System.Data.SqlClient.SqlDataReader reader = null;
System.Data.SqlClient.SqlCommand comd1 = new SqlCommand(sql, Conn);
comd1.Transaction = this.Trans;
reader = comd1.ExecuteReader();
while (reader.Read())
{
returnObj = reader[0];
}
reader.Close(); reader = null;
comd1.Dispose(); comd1 = null;
}
catch (Exception ex)
{
if (this.IsOnline && this._IsDrop)
{
this._IsDrop = false;
return GetValueBySQL(sql);
}
else
{
this._IsDrop = false;
System.Console.WriteLine(ex.Message);
throw ex;
}
}
if (returnObj == null) returnObj = "";
return returnObj;
}
public object GetValueBySQL(string sql, System.Data.SqlClient.SqlConnection conn)
{
object returnObj = null;
// System.Data.DataTable dt=this.GetDataTable(sql);
// if(dt.DefaultView.Count>0)
// {
// returnObj=dt.DefaultView[0][0];
// }
//
// dt.Dispose();dt=null;
// if(returnObj==null) returnObj="";
// return returnObj;
try
{
System.Data.SqlClient.SqlDataReader reader = null;
System.Data.SqlClient.SqlCommand comd1 = new SqlCommand(sql, conn);
comd1.Transaction = this.Trans;
reader = comd1.ExecuteReader();
while (reader.Read())
{
returnObj = reader[0];
}
reader.Close(); reader = null;
comd1.Dispose(); comd1 = null;
}
catch (Exception ex)
{
System.Console.WriteLine(ex.Message);
throw ex;
}
if (returnObj == null) returnObj = "";
return returnObj;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询