两个数据库使用函数,比较简单
主要是没有用那些现成的东西,而且可以设置timeout时间
protected DataSet execString(string sqlString)
{
SqlConnection CDOSuiteConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["CDOSuiteConnectionString"].ConnectionString);
try
{
CDOSuiteConnection.Open();
SqlCommand sqlCmd = new SqlCommand(sqlString, CDOSuiteConnection);
sqlCmd.CommandType = System.Data.CommandType.Text;
sqlCmd.CommandTimeout = 7200;
SqlDataAdapter da = new SqlDataAdapter(sqlCmd);
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
finally
{
if (CDOSuiteConnection != null)
{
CDOSuiteConnection.Close();
}
}
}
protected void execNonQuery(string sqlString)
{
SqlConnection CDOSuiteConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["CDOSuiteConnectionString"].ConnectionString);
try
{
CDOSuiteConnection.Open();
SqlCommand sqlCmd = new SqlCommand(sqlString, CDOSuiteConnection);
sqlCmd.CommandType = System.Data.CommandType.Text;
sqlCmd.CommandTimeout = 7200;
sqlCmd.ExecuteNonQuery();
}
finally
{
if (CDOSuiteConnection != null)
{
CDOSuiteConnection.Close();
}
}
}