统计下DataAccess常用方法
大家的数据访问层都常用什么方法呀。发发看,有人发了就别发拉,我想总结下 --------------------编程问答-------------------- 我常用。。。。。public bool insert(string sql) 哈哈~~~增删改查类似 --------------------编程问答-------------------- 用企业库吧 --------------------编程问答-------------------- up --------------------编程问答-------------------- Raptier生成数据库访问类
程序通过业务逻辑层,访问数据逻辑层,然后访问数据控制层,由数据控制层访问数据库访问类,数据库访问类操作数据库 --------------------编程问答-------------------- /******************************************************************
* Copyright(c) KiteSoft Studio
* Description :
* CreateDate : 2006-04-13 10:30:58
* Creater : Johnson Cao
* LastChangeDate:
* LastChanger :
* Version Info :
* ******************************************************************/
using System;
using System.Collections;
using System.Data;
namespace KiteSoft.Data
{
/// <summary>
/// Summary description for IDataAdapter.
/// </summary>
public inte易做图ce IDataAccess
{
#region Member
DataSourceType DataSourceType { get; set; }
string ConnectionString { get; set; }
Exception LastException { get; }
ConnectionState State { get; }
bool SupportStoredProcedure { get; }
#endregion
#region Connect Management
bool Connect();
bool Connect(string connectionString);
bool Disconnect();
void BeginTransaction();
void Rollback();
void Commit();
#endregion
#region Data Operation
bool ExecuteNonQuery(string SQL, params object[] Params);
bool ExecuteNonQueryByProc(string ProcName, params object[] Params);
// Ojbect operation
object LoadSingleObject(Type ObjectType, string SQL, params object[] Params);
object LoadSingleObjectByProc(Type ObjectType, string ProcName, params object[] Params);
bool LoadSingleObject(object AObj, string SQL, params object[] Params);
bool LoadSingleObjectByProc(object AObj, string ProcName, params object[] Params);
bool LoadList(IList List, Type ObjectType, string SQL, params object[] Params);
bool LoadListByProc(IList List, Type ObjectType, string ProcName, params object[] Params);
object LoadScalar(string SQL, params object[] Params);
object LoadScalarByProc(string ProcName, params object[] Params);
// DataSet operation
DataTable LoadSchema(string TableName);
bool FillDataSet(DataSet dataSet, string tableName, string SQL, params object[] Params);
bool FillDataSetByProc(DataSet dataSet, string tableName, string ProcName, params object[] Params);
IDataReader ExecuteReader(string SQL, params object[] Params);
IDataReader ExecuteReaderByProc(string ProcName, params object[] Params);
#endregion
}
}
--------------------编程问答-------------------- up --------------------编程问答-------------------- public static string FieldAsString(System.Data.DataRow row,string FieldName,string Format)
{
if (row.IsNull(FieldName))
{
return "";
}
object item = row[FieldName];
if (item.GetType() == System.Type.GetType("System.DateTime"))
{
DateTime d;
d = (DateTime)item;
return d.ToString(Format);
}
return item.ToString();
} --------------------编程问答-------------------- 用nhibernate 来访问数据库中的数据很方便 --------------------编程问答-------------------- up
补充:.NET技术 , C#