sqlexe.cs

来自「本程序是一个宾馆管理系统」· CS 代码 · 共 80 行

CS
80
字号
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>
/// SQLExe 的摘要说明
/// </summary>
/// 
namespace SQLExe
{
    public class SQLExe
    {
        public SQLExe()
        {
            //
            // TODO: 在此处添加构造函数逻辑
            //
        }
        public DataSet GetDataSet(string str)
        {
            SqlConnection ST_myCon = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
            SqlCommand ST_mycommand = new SqlCommand();
            SqlDataAdapter myAdapter = new SqlDataAdapter();
            DataSet ds = new DataSet();
            ST_mycommand.Connection = ST_myCon;
            ST_mycommand.CommandText = str;
          try
          {
                ST_myCon.Open();
                myAdapter.SelectCommand = ST_mycommand;
                myAdapter.Fill(ds);
                return ds;
           }
          catch (Exception exx)
            {
               throw (exx);
               
                
            }
            finally
            {
                ST_myCon.Close();
            }
           

        }
        public void SQLstr(string str)
        {
            SqlConnection ST_myCon = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
            SqlCommand ST_mycommand = new SqlCommand();
            ST_mycommand.Connection = ST_myCon;
            ST_mycommand.CommandText = str;
            try
            {
                ST_myCon.Open();
                ST_mycommand.ExecuteNonQuery();

            }
            catch (Exception exx)
            {
                throw (exx);
            }
            finally
            {
                ST_myCon.Close();
            }
            
 
        }
    }
 

}

⌨️ 快捷键说明

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