All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
解析在ASP.NET中调用存储过程的方法_.net资料_编程技术
delphi中break语句与continue语句的比较
你必须知道的.NET之对接口和抽象类_.net资料_编程技术
SQL初学者教程:掌握学会WHERE子句_[SQL Server教程]
PHP实例:PHP判断用户是否正确登录转到欢迎界面_[PHP教程]
SQL Server查询优化方法_[SQL Server教程]
ajax技术制作得在线歌词搜索功能_[AJAX教程]
Sql,server,2005的XML最佳实施策略(1)_[SQL,Server教程]
ajax和asp.net的配置文件_.net资料_编程技术
使用Forms,Authentication实现用户注册、登录,(二)用户注册与登录_[Asp.Net教程]
Reading number is top 10 pictures
去瑜伽会所面试的经过
关于提肛的健身效果
NeedWallpaper6
In 2013 hercules Arnold classic2
西班牙山村小景4
From China fortress sora aoi2
Embarrassing things comic collection1
The money of more than 100 countries and regions7
Breasts woman big set 2
A letter to parents choose world of warcraft seven big reason
Download software ranking
Unix video tutorial1
Visual C++界面编程技术
Unix video tutorial4
Boxer's Top ten classic battle3
jdk1.5
I'm come from Beijing2
Boxer vs Yellow4
Boxer Classic video1
Unix video tutorial8
Sora aoi, the maid, students' uniforms
delv published in(发表于) 2014/1/23 3:12:10 Edit(编辑)
Asp.net数据库操作类,c#_[Asp.Net教程]

Asp.net数据库操作类,c#_[Asp.Net教程]

Asp.net数据库操作类 c#_[Asp.Net教程]

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace Mysqlserver
{
///


/// SqlServerDataBase 的摘要说明
///

public class SqlServerDataBase
{
private string strError = null;
private int intCount = 0;
public SqlServerDataBase()
{
//
// TOD 在此处添加构造函数逻辑
//
}
///
/// 公开方法DBConn,返回数据库连接
///

///
public SqlConnection DBconn()
{
string strConn = "Server=(local);Database=GlobalMeetings;Uid=sa;pwd=";
try
{
return new SqlConnection(strConn);
}
catch (Exception)
{
return null;
}
}
///
/// 公开属性ErrorMessage,返回错误信息
///

public string ErrorMessage
{
get
{
return strError;
}
}

///
/// 根据查询语句从数据库检索数据
///

/// 查询语句
/// 数据库连接
/// 有数据则返回DataSet对象,否则返回null
public DataSet Select(string SelectString, SqlConnection sqlConn)
{
strError = "";
SqlConnection conn;
if (sqlConn == null)
{
conn = DBconn();
}
else
{
conn = sqlConn;
}
try
{
//若数据库连接的当前状态是关闭的,则打开连接
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter();
SqlCommand selectCommand = new SqlCommand(SelectString, conn);
selectCommand.CommandType = CommandType.Text;
mySqlDataAdapter.SelectCommand = selectCommand;
DataSet myDS = new DataSet();
mySqlDataAdapter.Fill(myDS);
return myDS;
}
catch (Exception e)
{
strError = "数据检索失败:" + e.Message;
return null;
}
finally
{
if (conn.State != ConnectionState.Closed)
{
conn.Close();
}
}
}
///
/// 更新数据库
///

/// Update Sql语句
/// 数据库连接
/// 更新成功返回true
public bool Update(string UpdateString, SqlConnection SqlConn)
{
return udiDataBase(UpdateString, SqlConn);
}







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.