我有mvc 4网站,下面有DataHelperClass来执行查询.我的问题有时候,网站通过例外作为标题.我用block来配置SqlCommand和SqlDataAdapter但没有成功.
请帮帮我,抱歉我的英语.
try
{
if (_conn.State == ConnectionState.Closed)
_conn.Open();
using (SqlCommand sqlCommand = new SqlCommand(query, _conn))
{
sqlCommand.CommandType = CommandType.StoredProcedure;
if (parameters != null)
sqlCommand.Parameters.AddRange(parameters);
//// check transaction is exist
if (_trans != null)
sqlCommand.Transaction = _trans;
DataTable dt = new DataTable();
using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand))
{
sqlDataAdapter.Fill(dt);
}
return dt;
}
}
finally
{
//// close connection automatically if transaction is not exist
if (_trans == null) { _conn.Close(); }
}
Run Code Online (Sandbox Code Playgroud) 我有一张 Excel 文件,其中包含多个图表。我从Excel中获取图表并将其保存到图片中。
我的代码:
workSheet = workBook.Sheets[1] as Excel._Worksheet;
Excel.ChartObjects chartObjects =(Excel.ChartObjects)workSheet.ChartObjects(Type.Missing);
int chartCount = chartObjects.Count;
for (int j = 1; j <= chartCount; j++)
{
Excel.ChartObject chart = (Excel.ChartObject)chartObjects.Item(j);
path = Path.Combine(Application.StartupPath, @"Img\" + chart.Chart.Name + ".bmp");
chart.Chart.Export(path, "BMP", true);
}
Run Code Online (Sandbox Code Playgroud)
但只导出空白图片。
请帮我