C# SQL数据库操作通用类
C# SQL数据库操作通用类
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
namespace Framework.DataBase
{
///
/// 通用数据库类
///
public class DataBase
{
private string ConnStr = null;
public DataBase()
{
ConnStr = ConfigurationSettings.AppSettings["ConnStr"];
}
public DataBase(string Str)
{
try
{
this.ConnStr = Str;
}
catch(Exception ex)
{
throw ex;
}
}
///
/// 返回connection对象
///
///
public SqlConnection ReturnConn()
{
SqlConnection Conn = new SqlConnection(ConnStr);
Conn.Open();
return Conn;
}
public void Dispose(SqlConnection Conn)
{
if(Conn!=null)
{
Conn.Close();
Conn.Dispose();
}
}
///
/// 运行SQL语句
///
///
public void RunProc(string SQL)
{
SqlConnection Conn;
Conn = new SqlConnection(ConnStr);
Conn.Open();
SqlCommand Cmd ;
Cmd = CreateCmd(SQL, Conn);
try
{
Cmd.ExecuteNonQuery();
}
catch
{
throw new Exception(SQL);
}
Dispose(Conn);
return;
}
///
/// 运行SQL语句返回DataReader
///
///
/// SqlDataReader对象.
public SqlDataReader RunProcGetReader(string SQL)
{
SqlConnection Conn;
Conn = new SqlConnection(ConnStr);
Conn.Open();
SqlCommand Cmd ;
Cmd = CreateCmd(SQL, Conn);
SqlDataReader Dr;
try
{
Dr = Cmd.ExecuteReader(CommandBehavior.Default);
}
catch
相关文档:
因现在的工作需要,
我得从WinForm的平台,
转型到WebForm的页面。
有一年多没有接触SQL Server了,
虽然大学时有点基础,
但也忘记得差不多了。
因为Asp.net型的B/S网站和WinForm的还是有点不同,
现在工作起来不是那么得心应手。
温故而知新,
就把以前实习时做的的网站源代码拿出来看看。
因为要用到SQL 2005S ......
CLR可以实现DML和DDL两种触发形式,但是本人一般不建议使用CLR的触发器,主要是考虑到效率问题。比如我们使用trigger来实现发mail等操作时,就要考虑pop3或是smtp等待时间,因为trigger本事就是个事务,也就是说,在smtp等待时间也算在了整个事务中,这样就会大大影响效率。
1.CLR DML触发器
DML指的是数据操作语言,也就 ......
bit:0或1的整型数字
int:从-2^31(-2,147,483,648)到2^31(2,147,483,647)的整型数字
smallint:从-2^15(-32,768)到2^15(32,767)的整型数字
tinyint:从0到255的整型数字
decimal:从-10^38到10^38-1的定精度与有效位数的数字
numeric:decimal的同义词
money:从-2^63(-922,337,203,685,477.580 ......
首先我很遗憾的告诉大家,因为微软的偷懒,目前UpdatePanel还不支持文件上传。变相的解决办法就是UpdatePanel中设置PostBackTrigger:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:FileUpload ID="FileUpload1" runat="serv ......
将b表中caller列的值插入a表中call列中。
create table a
(
fid int,
call varchar(20),
age int
)
create table b
(
fid int,
caller varchar(20),
parentId int
)
select * from a
select * from b
insert into a values(1,null,19)
insert into a values(2,n ......