文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > SqlDbHelper
侵权投诉

SqlDbHelper

sql # 公共数据库类

SqlConnection(connectionString))

{

using (SqlCommand command = new SqlCommand(sql, connection))

{

command.CommandType = commandType;//设置command的CommandType为指定的CommandType

//如果同时传入了参数,则添加这些参数

if (parameters != null)

{

foreach (SqlParameter parameter in parameters)

{

command.Parameters.Add(parameter);

}

}

//通过包含查询SQL的SqlCommand实例来实例化SqlDataAdapter

SqlDataAdapter adapter = new SqlDataAdapter(command);



adapter.Fill(data);//填充DataTable

}

}

return data;

}

/// <summary>

///

/// </summary>

/// <param name="sql">要执行的查询SQL文本命令</param>

/// <returns></returns>

public SqlDataReader ExecuteReader(string sql)

{

return ExecuteReader(sql, CommandType.Text, null);

}

/// <summary>

///

/// </summary>

/// <param name="sql">要执行的SQL语句</param>

/// <param name="commandType">要执行的查询语句的类型,如存储过程或者SQL文本命令</param>

/// <returns></returns>

public SqlDataReader ExecuteReader(string sql, CommandType commandType)

{

return ExecuteReader(sql, commandType, null);

}

/// <summary>

///

/// </summary>

/// <param name="sql">要执行的SQL语句</param>

/// <param name="commandType">要执行的查询语句的类型,如存储过程或者SQL文本命令</param>

/// <param name="parameters">Transact-SQL 语句或存储过程的参数数组</param>

/// <returns></returns>

public SqlDataReader ExecuteReader(string sql, CommandType commandType, SqlParameter[] parameters)

{

SqlConnection connection = new SqlConnection(connectionString);

SqlCommand command = new SqlCommand(sql, connection);

//如果同时传入了参数,则添加这些参数

if (parameters != null)

{

foreach (SqlParameter parameter in parameters)

{

command.Parameters.Add(parameter);

}

}

connection.Open();

//CommandBehavior.CloseConnection参数指示关闭Reader对象时关闭与

上一页第2页

你可能喜欢

热门文档

相关文档

  • SQLDBhelper数据库增删改查文档

    using System; usingSystem.Collections.Generic; usingSystem.Linq; usingSystem.Text; usingSystem.Data; usingSystem.Data.SqlClient; namespaceSqlDbHelper { public...

  • SqlDbHelper

    { /// ///DataHelper 的摘要说明 /// public static class SqlDbHelper { #region 连接字符串 /// /// 连接字符串 /// public static string SqlConn...

  • SqlDBHelper

    SqlDBHelper_计算机软件及应用_IT/计算机_专业资料 暂无评价0人阅读0次下载举报文档 SqlDBHelper_计算机软件及应用_IT/计算机_专业资料。using System; using ...

  • 微软SQL DBHelper类

    微软SQL DBHelper类_计算机软件及应用_IT/计算机_专业资料。对SQL SERVER数据库进行操作的底层类using System; using System.Data; using System.Data.Common; ...

  • 关于dbhelper详解

    关于dbhelper详解_IT/计算机_专业资料。关于dbhelper详解namespace Mode.DAL //...(sql语句,连接对象) int result = cmd.ExecuteNonQuery();//执行语句,并用一...

  • 安卓开发规范

    SqlDBHelper.java 描述:数据访问 3.1.7.com.hy.prss.mobile.android.util 例如:XmlUtil.java 描述:所有的零碎功能 包括处理 XmlUtil, JsonUtil,SharedPreference...

  • DbHelperSQL.cs

    using System.Data.SqlClient; using System.Configuration; using System.Data.Common; using System.Collections.Generic; namespace Maticsoft.DBUtility { /// /...

  • DBHelper(带参数C#)

    喜欢此文档的还喜欢 SqlDBHelper常用方法 5页 免费 DBHelper存储过程 3页 免费 关于dbhelper详解 2页 免费 DbHelperSQL.cs 14页 免费 DBHelper 3页 2财富值...

  • SQL 操作DBHelper

    ["DbHelperProvider"]; private static string dbConnectionString = ConfigurationManager.AppSettings["DbHelperConnectionS tring"]; private DbConnection connection; ...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email