代碼如下:
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;
}
新聞熱點
疑難解答
圖片精選