xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

  • 大小: 8KB
    文件類型: .cs
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2021-06-04
  • 語言: C#
  • 標簽: SQLServer??

資源簡介

SQL Server數(shù)據(jù)庫操作類是C#語言的,可實現(xiàn)對SQL Server數(shù)據(jù)庫的增刪改查詢等操作,并且該操作類可實現(xiàn)對圖片的存儲

資源截圖

代碼片段和文件信息

using?System;
using?System.Data;
using?System.Configuration;
using?System.Data.SqlClient;

namespace?SQLServerDatabase
{
????public?class?DatabaseOp
????{
????????private?string?SqlConnectionString;????//數(shù)據(jù)庫連接

????????///?
????????///?構(gòu)造函數(shù)
????????///?初始化連接數(shù)據(jù)庫參數(shù)
????????///?

????????public?DatabaseOp()
????????{
????????????SqlConnectionString?=?“Data?Source=.;Initial?Catalog=DatabaseName;User?ID=sa;pwd=123456;Connection?Lifetime=0;max?pool?size=200“;
????????}

????????///?
????????///?構(gòu)造函數(shù)
????????///?初始化連接數(shù)據(jù)庫參數(shù)
????????///?

????????///?連接對象
????????public?DatabaseOp(string?ConSqlServer)
????????{
????????????SqlConnectionString?=?ConSqlServer;
????????}

????????///?
????????///?打開數(shù)據(jù)庫連接
????????///?

????????///?連接
????????public?void?Open(SqlConnection?cn)
????????{
????????????if?(cn.State?==?ConnectionState.Closed)
????????????{
????????????????cn.Open();
????????????}
????????}

????????///?
????????///?關(guān)閉數(shù)據(jù)庫連接
????????///?

????????///?連接
????????public?void?Close(SqlConnection?cn)
????????{
????????????if?(cn?!=?null)
????????????{
????????????????if?(cn.State?==?ConnectionState.Open)
????????????????{
????????????????????cn.Close();
????????????????}
????????????????cn.Dispose();
????????????}
????????}

????????///?
????????///?查詢
????????///?

????????///?SQL語句
????????///?是否存在
????????public?bool?ChaXun(string?strSql)
????????{
????????????SqlConnection?cn?=?new?SqlConnection(SqlConnectionString);
????????????SqlCommand?cmd?=?new?SqlCommand();
????????????try
????????????{
????????????????Open(cn);
????????????????cmd?=?new?SqlCommand(strSql?cn);
????????????????return?cmd.ExecuteReader().Read();
????????????}
????????????catch?(Exception?e)
????????????{
????????????????throw?new?Exception(e.Message);
????????????}
????????????finally
????????????{
????????????????cmd.Dispose();
????????????????Close(cn);
????????????}
????????}

????????///?
????????///?查詢
????????///?

????????///?SQL語句
????????///?第一行第一列結(jié)果
????????public?string?ChaXun2(string?strSql)
????????{
????????????SqlConnection?cn?=?new?SqlConnection(SqlConnectionString);
????????????SqlCommand?cmd?=?new?SqlCommand();
????????????try
????????????{
????????????????Open(cn);
????????????????cmd?=?new?SqlCommand(strSql?cn);
????????????????return?cmd.ExecuteScalar().ToString().Trim();
????????????}
????????????catch?(Exception?e)
????????????{
????????????????throw?new?Exception(e.Message);
????????????}
????????????finally
????????????{
????????????????cmd.Dispose();
????????????????Close(cn);
????????????}
????????}

????????///?

????????///?查詢(SqlDataReader)
??????

評論

共有 條評論

相關(guān)資源