两个数据库使用函数,比较简单
2008-07-16 14:23
393 查看
主要是没有用那些现成的东西,而且可以设置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();
}
}
}
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();
}
}
}
相关文章推荐
- 两个数据库使用函数,比较简单
- 两个简单的数据库操作函数,避免对不同的表结构使用不同的update语句
- 使用Red Gate Sql Data Compare 数据库同步工具进行SQL Server的两个数据库的数据比较、同步
- 不使用strcmp函数比较两个字符串的大小
- 使用strncmp()函数比较两个字符串指定数量的字符
- 编写一个函数比较两个整数大小,但不能使用任何比较操作符
- DES的两个简单的加密、解密函数(C#中使用)
- 连接池技术与传统数据库连接的比较和简单使用
- 编写函数求两个整数 a 和 b 之间的较大值。要求不能使用if, while, switch, for, ?: 以及任何的比较语句
- 编写函数求两个整数 a 和 b 之间的较大值。要求不能使用if, while, switch, for, ?: 以及任何的比较语句
- 使用Red Gate Sql Compare 数据库同步工具进行SQL Server的两个数据库的结构比较、同步
- C#中使用Equals()函数比较两个字符串是否相同
- 自己写的数据库访问组件 使用ADO.NET 比较简单
- C#与ActionScript3.0比较 -> 函数使用之区别
- C语言 函数的简单使用(库函数和自定义函数)
- [iOS]数据持久化-数据库的简单使用
- Android glide使用简单例子(比较全的例子,包含gif)
- 使用 Diff 和 Meld 工具比较两个目录的不同处
- php简单实现查询数据库返回json数据(返回json数据函数实例)
- iOS MesaSQLite数据库简单使用