国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

asp.net Oracle數據庫訪問操作類

2024-07-10 12:46:10
字體:
來源:轉載
供稿:網友

代碼如下:
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Data;
using System.Data.OracleClient;
using System.Configuration;
using System.Data.Common;
using System.Collections.Generic;

    /// <summary>
    /// 數據訪問抽象基礎類
    ///
    /// </summary>
public class DBBase
{


    //數據庫連接字符串(web.config來配置),可以動態更改connectionString支持多數據庫.       
    public static string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString1"].ToString();
    public DBBase()
    {
    }

    #region 檢查用戶名是否存在
    /// <summary>
    /// 檢查用戶名是否存在,存在返回true,不存在返回false
    /// </summary>
    /// <param name="strSql"></param>
    /// <returns></returns>
    public static bool Exists(string strSql)
    {

        using (OracleConnection connection = new OracleConnection(connectionString))
        {
            connection.Open();
            OracleCommand myCmd = new OracleCommand(strSql, connection);
            try
            { 
                object obj = myCmd.ExecuteScalar(); //返回結果的第一行一列
                myCmd.Parameters.Clear();
                if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
                {
                    return false;
                }
                else
                {
                    return true;
                }          

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 盱眙县| 张家界市| 申扎县| 新营市| 馆陶县| 苗栗市| 蒙城县| 江油市| 尼玛县| 壤塘县| 科技| 武陟县| 孝感市| 博兴县| 肥东县| 孙吴县| 镇安县| 广元市| 会泽县| 雷波县| 嵊泗县| 湄潭县| 信宜市| 白河县| 商水县| 奉节县| 边坝县| 福泉市| 永城市| 辽源市| 宁河县| 乡城县| 鞍山市| 天津市| 榆林市| 龙井市| 安吉县| 安丘市| 鄄城县| 肥东县| 文化|