DbHelperSQL.cs

(开头部分) 18KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections;
using System.Collections.Specialized;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace dbToCode //可以修改成实际项目的命名空间名称
{
	/// <summary>
	/// Copyright (C) 2004-2008 LiTianPing 
	/// 数据访问基础类(基于SQLServer)
	/// 用户可以修改满足自己项目的需要。
	/// </summary>
	public abstract class DbHelperSQL
	{
		//数据库连接字符串(web.config来配置)
		//<add key="ConnectionString" value="server=127.0.0.1;database=DATABASE;uid=sa;pwd=" />	

        private static string GetConString()
        {
            CodeSaveOption option = CodeSaveOption.FileToObj(new CodeSaveOption());
            string strSql = "";
            if (option != null)
            {
                strSql = "Data Source=" + option.ServerPath + ";Initial Catalog=" + option.DataBase + ";Persist Security Info=True;User ID=" + option.UserID + ";Password=" + option.PassWrod + "";
            }
            return strSql;
        }
        protected static string connectionString = GetConString();
		public DbHelperSQL()
		{			
		}
		
		#region  执行简单SQL语句

		/// <summary>
		/// 执行SQL语句,返回影响的记录数
		/// </summary>
		/// <param name="SQLString">SQL语句</param>
		/// <returns>影响的记录数</returns>
		public static int ExecuteSql(string SQLString)
		{
			using (SqlConnection connection = new SqlConnection(connectionString))
			{				
				using (SqlCommand cmd = new SqlCommand(SQLString,connection))
				{
					try
					{		
						connection.Open();
						int rows=cmd.ExecuteNonQuery();
						return rows;
					}
					catch(System.Data.SqlClient.SqlException E)
					{					
						connection.Close();
						throw new Exception(E.Message);
					}
				}				
			}
后面还有 539 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。