using System.Data
using System.Data.SqlClient
using System.Configuration
using System.Web
using System.Web.Security
using System.Web.UI
using System.Web.UI.HtmlControls
using System.Web.UI.WebControls
using System.Web.UI.WebControls.WebParts
using MySql.Data.MySqlClient
public class ntko_mysql_class
{
public ntko_mysql_class()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
/// <summary>
/// </summary>
public MySqlConnection connstr//连接字符串
/// <summary>
///定义示例程序文档保存为其它格式文档路径
/// </summary>
public string demotitle, officepath, htmlpath, pdfpath, attachpath
/// <summary>
/// 获取数据库联接字符串
/// </summary>
public string getconnstr()
{
string constr
constr = System.Configuration.ConfigurationManager.AppSettings["mysql_dbconn"]
return constr
}
public void open() //打开数据库
{
string constr
constr = getconnstr()
connstr = new MySqlConnection(constr)
connstr.Open()
}
public void close() //关闭数据库
{
connstr.Dispose()
connstr.Close()
}
/// <summary>
/// 执行SQL语句
/// </summary>
/// <param name="sql">SQL语句</param>
public void execsql(string sql)
{
open()
MySqlCommand cmd = new MySqlCommand(sql, connstr)
cmd.ExecuteNonQuery()
close()
}
/// <summary>
/// 返回DataSet对象
/// </summary>
/// <param name="sql"></param>
/// <returns></returns>
public DataSet dataset(string sql)
{
open()
MySqlDataAdapter rs = new MySqlDataAdapter(sql, connstr)
DataSet ds = new DataSet()
rs.Fill(ds)
return ds
}
/// <summary>
/// 返回DataView对象
/// </summary>
/// <param name="sql"></param>
/// <returns></returns>
public DataView dataview(string sql)
{
DataSet ds = new DataSet()
ds = dataset(sql)
DataView dv = new DataView(ds.Tables[0])
return dv
}
/// <summary>
/// 返回DataReader对象
/// </summary>
/// <param name="sql"></param>
/// <returns></returns>
public MySqlDataReader datareader(string sql)
{
open()
MySqlCommand cmd = new MySqlCommand(sql, connstr)
MySqlDataReader dr = cmd.ExecuteReader()
return dr
}
/// <summary>
/// 获取示例程序标题
/// </summary>
/// <returns></returns>
public string getdemotitle()
{
demotitle = System.Configuration.ConfigurationManager.AppSettings["demotitle"]
return demotitle
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)