⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dachelper.cs

📁 usb-com for sms 自己开发的类 可以借鉴下
💻 CS
字号:
using System;
using System.Data;
using System.Data.SqlClient;

namespace IPP.SMS
{
	/// <summary>
	/// Summary description for DacHelper.
	/// </summary>
	public class DacHelper
	{
		private SqlCommand _command = null;
		private string _connectionString = AppConst.ConnectionString;

		public DacHelper(string paramCommandText, CommandType paramCommandType) 
		{
			_command = new SqlCommand(paramCommandText);
			_command.CommandType = paramCommandType;
		}
		public DacHelper(string paramCommandText)
		{
			_command = new SqlCommand(paramCommandText);
			_command.CommandType =CommandType.Text;
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="paramDataSetName"></param>
		/// <returns></returns>
		public DataSet ExecuteDataSet(string paramDataSetName)
		{
			DataSet ds;
			SqlConnection con = new SqlConnection(_connectionString);
			try
			{
				con.Open();
				_command.Connection = con;
				SqlDataAdapter sqlDA = new SqlDataAdapter();
				sqlDA.SelectCommand = _command;
				ds = new DataSet();
				sqlDA.Fill( ds, paramDataSetName );
			}
			catch(Exception exp)
			{
				
				throw exp;
			}
			finally
			{
				con.Close();
			}
			return ds;
		}
		public int ExecuteNoQuery()
		{
			int result = AppConst.IntNull;
			SqlConnection con = new SqlConnection(_connectionString);
			try
			{
				con.Open();
				_command.Connection = con;
				result = _command.ExecuteNonQuery();
			}
			catch(Exception exp)
			{
				
				throw exp;
			}
			finally
			{
				con.Close();
			}

			return result;
		}

		public SqlCommand Command 
		{
			get { return _command; }
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -