Winfrom中连接数据库,该如何解决
Winfrom中连接数据库
谁能提供一个完整的Winfrom中连接数据库的类,先在这里谢谢了。。。
------解决方案--------------------
百度 搜索 SqlHeler.cs
------解决方案--------------------
谁能提供一个完整的Winfrom中连接数据库的类,先在这里谢谢了。。。
------解决方案--------------------
百度 搜索 SqlHeler.cs
------解决方案--------------------
namespace ESWS
{
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Reflection;
using ESWS;
internal class MySqlHelper : IDisposable
{
private MySqlCommand mySqlCommand;
private MySqlConnection mySqlConnection;
private MySqlDataAdapter mySqlDataAdapter;
private MySqlTransaction myTransaction;
protected virtual void AddParameters(MySqlCommand command, MySqlParameter[] parameters)
{
foreach (MySqlParameter parameter in parameters)
{
command.Parameters.AddWithValue(parameter.ParameterName, parameter.Value);
}
}
internal void BegionTransaction()
{
if (this.DBConnection.State != ConnectionState.Open)
{
this.DBConnection.Open();
}
this.myTransaction = this.DBConnection.BeginTransaction();
}
internal void Commit()
{
this.DBTransaction.Commit();
}
protected MySqlCommand CreateCommand(string commandText)
{
return this.CreateCommand(commandText, CommandType.Text);
}
protected MySqlCommand CreateCommand(string commandText, CommandType commandType)
{
return this.CreateCommand(commandText, commandType, null);
}
protected MySqlCommand CreateCommand(string commandText, MySqlParameter[] parameters)