富贵资源网 Design By www.hznty.com
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
/// <summary>
/// SqlConnections 的摘要说明
/// </summary>
namespace System.mySQLConnection
{
public class SqlConnections
{
//当前连接的是第几个。
static int count = 0;
//最大连接量
static int maxCount = 30;
static SqlConnection[] sqlConns = new SqlConnection[maxCount];
//自己创建自己
static SqlConnections myConn = new SqlConnections();
//初始化
private SqlConnections()
{
for (int i = 0; i < maxCount; i++)
{
sqlConns[i] = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ADOStr"].ToString());
}
}
//根据条件来获取不同的表,与字段。
public static DataTable GetDataTable(String sqlTest, String tableName)
{
try
{
DataSet myDS = new DataSet();
SqlDataAdapter myAdapater = new SqlDataAdapter(sqlTest, SqlConnections.GetSQLConnection());
myAdapater.Fill(myDS, tableName);
return myDS.Tables[tableName];
}
catch (SqlException sqlE)
{
return null;
}
}
// 获取数据库连接
public static SqlConnection GetSQLConnection()
{
try
{
try
{
sqlConns[count].Close();
}
catch (Exception eeX)
{
}
return sqlConns[count];
}
finally
{
//当前个数自加。。
if (count == (maxCount - 1))
{
count = 0;
}
else
{
count++;
}
}
}
//返回一个参数
public static String GetNumOneField(String sqlTxt)
{
SqlConnection sqlConnTemp = SqlConnections.GetSQLConnection();
try
{
SqlCommand sqlCommT = new SqlCommand(sqlTxt, sqlConnTemp);
sqlConnTemp.Open();
return sqlCommT.ExecuteScalar().ToString();
}
catch (Exception sqlE)
{
return "没有";
}
finally
{
sqlConnTemp.Close();
}
}
//返回一个参数
public static String GetNumOneField(SqlConnection sqlConnTemp,SqlTransaction tempSqlTran ,String sqlTxt)
{
try
{
SqlCommand sqlCommT = new SqlCommand(sqlTxt, sqlConnTemp);
sqlCommT.Transaction = tempSqlTran;
return sqlCommT.ExecuteScalar().ToString();
}
catch (Exception sqlE)
{
return "没有";
}
finally
{
//sqlConnTemp.Close();
}
}
/// <summary>
/// 做 ,修改,删除,
/// </summary>
/// <param name="sqlTxt">执行的SQL语句</param>
/// <returns>返回的结果影响多少行</returns>
public static int UpdateOrDelete(String sqlTxt)
{
SqlConnection sqlConnTemp = SqlConnections.GetSQLConnection();
try
{
SqlCommand sqlCommT = new SqlCommand(sqlTxt, sqlConnTemp);
sqlConnTemp.Open();
return sqlCommT.ExecuteNonQuery();
}
catch (SqlException sqlE)
{
return 0;
}
finally
{
//sqlConnTemp.Close();
}
}
public static int UpdateOrDelete(CommandType _CommandType, SqlParameter[] _sqlParas, String sqlTxt)
{
SqlConnection sqlConnTemp = SqlConnections.GetSQLConnection();
try
{
SqlCommand sqlCommT = new SqlCommand(sqlTxt, sqlConnTemp);
sqlCommT.CommandType = _CommandType;
sqlCommT.Parameters.Clear();
for (int a = 0; a < _sqlParas.Length; a++)
{
sqlCommT.Parameters.Add(_sqlParas[a]);
}
sqlConnTemp.Open();
return sqlCommT.ExecuteNonQuery();
}
catch (SqlException sqlE)
{
return 0;
}
finally
{
//sqlConnTemp.Close();
}
}
/// <summary>
/// 带事务的增,删,改数据执行方法(警告:该方法必须 手动开关数据,而且还有手动的提交事务。否则不能更新数据)
/// </summary>
/// <param name="_SqlConn">数据库连接对象</param>
/// <param name="_SqlTran">事务对象</param>
/// <param name="sqlTxt">执行的Sql语句</param>
/// <returns></returns>
public static int UpdateOrDelete(SqlConnection _SqlConn,SqlTransaction _SqlTran, String sqlTxt)
{
SqlConnection sqlConnTemp = _SqlConn;
try
{
SqlCommand sqlCommT = new SqlCommand(sqlTxt, sqlConnTemp);
sqlCommT.Transaction = _SqlTran;
sqlConnTemp.Open();
return sqlCommT.ExecuteNonQuery();
}
catch (SqlException sqlE)
{
return 0;
}
finally
{
//sqlConnTemp.Close();
}
}
public static int UpdateOrDelete(SqlConnection _SqlConn, SqlTransaction _SqlTran, CommandType _CommandType, SqlParameter [] _sqlParas, String sqlTxt)
{
SqlConnection sqlConnTemp = _SqlConn;
try
{
SqlCommand sqlCommT = new SqlCommand(sqlTxt, sqlConnTemp);
sqlCommT.Transaction = _SqlTran;
sqlCommT.CommandType = _CommandType;
sqlCommT.Parameters.Clear();
for (int a = 0; a < _sqlParas.Length; a++)
{
sqlCommT.Parameters.Add(_sqlParas[a]);
}
return sqlCommT.ExecuteNonQuery();
}
catch (SqlException sqlE)
{
return 0;
}
finally
{
// sqlConnTemp.Close();
}
}
/// <summary>
/// 有存储过的查询
/// </summary>
/// <param name="StoredProcedureName">存储过程的名字</param>
/// <param name="sqlParas">所有参数</param>
/// <param name="tableName">表名</param>
/// <returns>DataTable的结果集</returns>
public static DataTable GetDataTable(String StoredProcedureName, SqlParameter [] sqlParas,String tableName)
{
try
{
DataSet myDS = new DataSet();
SqlDataAdapter myAdapater = new SqlDataAdapter(StoredProcedureName, SqlConnections.GetSQLConnection());
myAdapater.SelectCommand.CommandType = CommandType.StoredProcedure;
for (int i = 0; i < sqlParas.Length; i++)
{
//if (myAdapater.SelectCommand.Parameters.Contains(sqlParas[i]))
//myAdapater.SelectCommand.Parameters.RemoveAt(sqlParas[i].ParameterName);
myAdapater.SelectCommand.Parameters.Add(sqlParas[i]);
}
myAdapater.Fill(myDS, tableName);
myAdapater.SelectCommand.Parameters.Clear();
myAdapater.Dispose();
return myDS.Tables[tableName];
}
catch (SqlException sqlE)
{
return null;
}
}
}
}
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
/// <summary>
/// SqlConnections 的摘要说明
/// </summary>
namespace System.mySQLConnection
{
public class SqlConnections
{
//当前连接的是第几个。
static int count = 0;
//最大连接量
static int maxCount = 30;
static SqlConnection[] sqlConns = new SqlConnection[maxCount];
//自己创建自己
static SqlConnections myConn = new SqlConnections();
//初始化
private SqlConnections()
{
for (int i = 0; i < maxCount; i++)
{
sqlConns[i] = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ADOStr"].ToString());
}
}
//根据条件来获取不同的表,与字段。
public static DataTable GetDataTable(String sqlTest, String tableName)
{
try
{
DataSet myDS = new DataSet();
SqlDataAdapter myAdapater = new SqlDataAdapter(sqlTest, SqlConnections.GetSQLConnection());
myAdapater.Fill(myDS, tableName);
return myDS.Tables[tableName];
}
catch (SqlException sqlE)
{
return null;
}
}
// 获取数据库连接
public static SqlConnection GetSQLConnection()
{
try
{
try
{
sqlConns[count].Close();
}
catch (Exception eeX)
{
}
return sqlConns[count];
}
finally
{
//当前个数自加。。
if (count == (maxCount - 1))
{
count = 0;
}
else
{
count++;
}
}
}
//返回一个参数
public static String GetNumOneField(String sqlTxt)
{
SqlConnection sqlConnTemp = SqlConnections.GetSQLConnection();
try
{
SqlCommand sqlCommT = new SqlCommand(sqlTxt, sqlConnTemp);
sqlConnTemp.Open();
return sqlCommT.ExecuteScalar().ToString();
}
catch (Exception sqlE)
{
return "没有";
}
finally
{
sqlConnTemp.Close();
}
}
//返回一个参数
public static String GetNumOneField(SqlConnection sqlConnTemp,SqlTransaction tempSqlTran ,String sqlTxt)
{
try
{
SqlCommand sqlCommT = new SqlCommand(sqlTxt, sqlConnTemp);
sqlCommT.Transaction = tempSqlTran;
return sqlCommT.ExecuteScalar().ToString();
}
catch (Exception sqlE)
{
return "没有";
}
finally
{
//sqlConnTemp.Close();
}
}
/// <summary>
/// 做 ,修改,删除,
/// </summary>
/// <param name="sqlTxt">执行的SQL语句</param>
/// <returns>返回的结果影响多少行</returns>
public static int UpdateOrDelete(String sqlTxt)
{
SqlConnection sqlConnTemp = SqlConnections.GetSQLConnection();
try
{
SqlCommand sqlCommT = new SqlCommand(sqlTxt, sqlConnTemp);
sqlConnTemp.Open();
return sqlCommT.ExecuteNonQuery();
}
catch (SqlException sqlE)
{
return 0;
}
finally
{
//sqlConnTemp.Close();
}
}
public static int UpdateOrDelete(CommandType _CommandType, SqlParameter[] _sqlParas, String sqlTxt)
{
SqlConnection sqlConnTemp = SqlConnections.GetSQLConnection();
try
{
SqlCommand sqlCommT = new SqlCommand(sqlTxt, sqlConnTemp);
sqlCommT.CommandType = _CommandType;
sqlCommT.Parameters.Clear();
for (int a = 0; a < _sqlParas.Length; a++)
{
sqlCommT.Parameters.Add(_sqlParas[a]);
}
sqlConnTemp.Open();
return sqlCommT.ExecuteNonQuery();
}
catch (SqlException sqlE)
{
return 0;
}
finally
{
//sqlConnTemp.Close();
}
}
/// <summary>
/// 带事务的增,删,改数据执行方法(警告:该方法必须 手动开关数据,而且还有手动的提交事务。否则不能更新数据)
/// </summary>
/// <param name="_SqlConn">数据库连接对象</param>
/// <param name="_SqlTran">事务对象</param>
/// <param name="sqlTxt">执行的Sql语句</param>
/// <returns></returns>
public static int UpdateOrDelete(SqlConnection _SqlConn,SqlTransaction _SqlTran, String sqlTxt)
{
SqlConnection sqlConnTemp = _SqlConn;
try
{
SqlCommand sqlCommT = new SqlCommand(sqlTxt, sqlConnTemp);
sqlCommT.Transaction = _SqlTran;
sqlConnTemp.Open();
return sqlCommT.ExecuteNonQuery();
}
catch (SqlException sqlE)
{
return 0;
}
finally
{
//sqlConnTemp.Close();
}
}
public static int UpdateOrDelete(SqlConnection _SqlConn, SqlTransaction _SqlTran, CommandType _CommandType, SqlParameter [] _sqlParas, String sqlTxt)
{
SqlConnection sqlConnTemp = _SqlConn;
try
{
SqlCommand sqlCommT = new SqlCommand(sqlTxt, sqlConnTemp);
sqlCommT.Transaction = _SqlTran;
sqlCommT.CommandType = _CommandType;
sqlCommT.Parameters.Clear();
for (int a = 0; a < _sqlParas.Length; a++)
{
sqlCommT.Parameters.Add(_sqlParas[a]);
}
return sqlCommT.ExecuteNonQuery();
}
catch (SqlException sqlE)
{
return 0;
}
finally
{
// sqlConnTemp.Close();
}
}
/// <summary>
/// 有存储过的查询
/// </summary>
/// <param name="StoredProcedureName">存储过程的名字</param>
/// <param name="sqlParas">所有参数</param>
/// <param name="tableName">表名</param>
/// <returns>DataTable的结果集</returns>
public static DataTable GetDataTable(String StoredProcedureName, SqlParameter [] sqlParas,String tableName)
{
try
{
DataSet myDS = new DataSet();
SqlDataAdapter myAdapater = new SqlDataAdapter(StoredProcedureName, SqlConnections.GetSQLConnection());
myAdapater.SelectCommand.CommandType = CommandType.StoredProcedure;
for (int i = 0; i < sqlParas.Length; i++)
{
//if (myAdapater.SelectCommand.Parameters.Contains(sqlParas[i]))
//myAdapater.SelectCommand.Parameters.RemoveAt(sqlParas[i].ParameterName);
myAdapater.SelectCommand.Parameters.Add(sqlParas[i]);
}
myAdapater.Fill(myDS, tableName);
myAdapater.SelectCommand.Parameters.Clear();
myAdapater.Dispose();
return myDS.Tables[tableName];
}
catch (SqlException sqlE)
{
return null;
}
}
}
}
富贵资源网 Design By www.hznty.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
富贵资源网 Design By www.hznty.com
暂无评论...
稳了!魔兽国服回归的3条重磅消息!官宣时间再确认!
昨天有一位朋友在大神群里分享,自己亚服账号被封号之后居然弹出了国服的封号信息对话框。
这里面让他访问的是一个国服的战网网址,com.cn和后面的zh都非常明白地表明这就是国服战网。
而他在复制这个网址并且进行登录之后,确实是网易的网址,也就是我们熟悉的停服之后国服发布的暴雪游戏产品运营到期开放退款的说明。这是一件比较奇怪的事情,因为以前都没有出现这样的情况,现在突然提示跳转到国服战网的网址,是不是说明了简体中文客户端已经开始进行更新了呢?