本文整理汇总了C#中MySql.Data.MySqlClient.MySqlCommand类的典型用法代码示例。如果您正苦于以下问题:C# MySql.Data.MySqlClient.MySqlCommand类的具体用法?C# MySql.Data.MySqlClient.MySqlCommand怎么用?C# MySql.Data.MySqlClient.MySqlCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MySql.Data.MySqlClient.MySqlCommand类属于命名空间,在下文中一共展示了MySql.Data.MySqlClient.MySqlCommand类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: EditSptInfo
private void EditSptInfo(SettingsData returnEditedsettingsData)
{
MySql.Data.MySqlClient.MySqlConnection msqlConnection = null;
msqlConnection = new MySql.Data.MySqlClient.MySqlConnection("server=localhost;user id=root;Password=technicise;database=sptdb;persist security info=False");
try
{ //define the command reference
MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
msqlCommand.Connection = msqlConnection;
msqlConnection.Open();
int idSptinfo = 1;
msqlCommand.CommandText = "UPDATE sptinfo SET name='" + returnEditedsettingsData.Name + "', address='" + returnEditedsettingsData.Address + "', phone='" +
returnEditedsettingsData.Phone + "', bill_disclaimer='" + returnEditedsettingsData.BillDisclaimer + "', invoice_prefix='" + returnEditedsettingsData.InvoicePrefix +
"' WHERE id_sptinfo='" + idSptinfo + "'; ";
msqlCommand.ExecuteNonQuery();
}
catch (Exception er)
{
MessageBox.Show(er.Message);
}
finally
{
//always close the connection
msqlConnection.Close();
}
}
开发者ID:shuiping150,项目名称:SalesPurchaseTracker,代码行数:29,代码来源:SPTSettingsWindow.xaml.cs
示例2: FetchePassword
public static string FetchePassword()
{
string passwordStr = string.Empty;
MySql.Data.MySqlClient.MySqlConnection msqlConnection = null;
msqlConnection = new MySql.Data.MySqlClient.MySqlConnection("server=localhost;user id=root;Password=technicise;database=sptdb;persist security info=False");
try
{ //define the command reference
MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
msqlCommand.Connection = msqlConnection;
msqlConnection.Open();
msqlCommand.CommandText = "Select password from sptinfo;";
MySql.Data.MySqlClient.MySqlDataReader msqlReader = msqlCommand.ExecuteReader();
msqlReader.Read();
passwordStr = msqlReader.GetString("password");
}
catch (Exception er)
{
//Assert//.Show(er.Message);
}
finally
{
//always close the connection
msqlConnection.Close();
}
return passwordStr;
}
开发者ID:shuiping150,项目名称:SalesPurchaseTracker,代码行数:34,代码来源:FetchSPTSettings.cs
示例3: SqlScalar
/// <summary>
/// Для выполнения запросов к MySQL с возвращением 1 параметра.
/// </summary>
/// <param name="sql">Текст запроса к базе данных</param>
/// <param name="connection">Строка подключения к базе данных</param>
/// <returns>Возвращает значение при успешном выполнении запроса, текст ошибки - при ошибке.</returns>
public static MyResult SqlScalar(string sql, string connection)
{
MyResult result = new MyResult();
try
{
MySql.Data.MySqlClient.MySqlConnection connRC = new MySql.Data.MySqlClient.MySqlConnection(connection);
MySql.Data.MySqlClient.MySqlCommand commRC = new MySql.Data.MySqlClient.MySqlCommand(sql, connRC);
connRC.Open();
try
{
result.ResultText = commRC.ExecuteScalar().ToString();
result.HasError = false;
}
catch (Exception ex)
{
result.ErrorText = ex.Message;
result.HasError = true;
}
connRC.Close();
}
catch (Exception ex)//Этот эксепшн на случай отсутствия соединения с сервером.
{
result.ErrorText = ex.Message;
result.HasError = true;
}
return result;
}
开发者ID:nebosvod,项目名称:notify,代码行数:34,代码来源:Main.cs
示例4: assignEstimator
public static void assignEstimator(estimateInfo estimateToEdit)
{
MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection();
try
{ //define the command reference
MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
msqlCommand.Connection = msqlConnection;
msqlCommand.CommandText = "UPDATE estimate SET [email protected] WHERE [email protected]";
msqlCommand.Parameters.AddWithValue("@estimator", estimateToEdit.estimator);
msqlCommand.Parameters.AddWithValue("@appNo", estimateToEdit.appsNo);
msqlCommand.ExecuteNonQuery();
}
catch (Exception er)
{
}
finally
{
//always close the connection
msqlConnection.Close();
}
}
开发者ID:sayan801,项目名称:ElectricSupplyCustomerManagmentSystem,代码行数:25,代码来源:DbInteraction.cs
示例5: ConnectInsertToDoListTable
public static void ConnectInsertToDoListTable(ToDoData tdData)
{
//define the connection reference and initialize it
MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection();
try
{ //define the command reference
MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
msqlCommand.Connection = msqlConnection;
msqlCommand.CommandText = "INSERT INTO to_do(date_time,to_do,id)" + "VALUES(@date_time,@to_do,@id)";
msqlCommand.Parameters.AddWithValue("@date_time", tdData.date_time);
msqlCommand.Parameters.AddWithValue("@to_do", tdData.to_do);
msqlCommand.Parameters.AddWithValue("@id", tdData.id);
msqlCommand.ExecuteNonQuery();
}
catch (Exception er)
{
}
finally
{
//always close the connection
msqlConnection.Close();
}
}
开发者ID:shuiping150,项目名称:SalesPurchaseTracker,代码行数:28,代码来源:DbInteraction.cs
示例6: assignDonor
public static void assignDonor(PatientInfo patientData)
{
MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection();
try
{ //define the command reference
MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
msqlCommand.Connection = msqlConnection;
msqlCommand.CommandText = "UPDATE patient SET [email protected]_donor, assigned_donor_contact = @assigned_donor_contact WHERE [email protected]_id";
msqlCommand.Parameters.AddWithValue("@patient_id", patientData.id);
msqlCommand.Parameters.AddWithValue("@assigned_donor", patientData.assignedDonor);
msqlCommand.Parameters.AddWithValue("@assigned_donor_contact", patientData.donorContact);
msqlCommand.ExecuteNonQuery();
}
catch (Exception er)
{
}
finally
{
//always close the connection
msqlConnection.Close();
}
}
开发者ID:sayan801,项目名称:BloodDonationManagement,代码行数:25,代码来源:DbInteraction.cs
示例7: StateChanged_Executed
void StateChanged_Executed(object sender, ExecutedEventArgs e)
{
string messgae = "불러오기를 완료하였습니다.";
AMR_MST04Model model = new AMR_MST04Model();
model = (AMR_MST04Model)e.Parameter;
MySqlManage crud = new MySqlManage(ConfigurationManager.ConnectionStrings["MySQL"].ConnectionString);
DataSet ds = new DataSet();
MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand();
cmd.CommandText = "CALL sp_load(@sno, @datefrom, @dateto);";
cmd.Parameters.AddWithValue("@sno", model.MST04SNO);
cmd.Parameters.AddWithValue("@datefrom", model.From.ToString("yyyy-MM-dd") + " 00");
cmd.Parameters.AddWithValue("@dateto", model.To.ToString("yyyy-MM-dd") + " 00");
ds = crud.CallSPMariaDBTable(crud.Connection, cmd);
if (ds.Tables.Count > 0)
{
model.DataTable = ds.Tables[0];
CurrentForm.SearchComplete(model);
}
CurrentForm.ShowMessage(messgae);
}
开发者ID:shine8319,项目名称:DLS,代码行数:26,代码来源:G02I01ModulePresenter.cs
示例8: Register_AfterCheck
public bool Register_AfterCheck(string Username, string Password, string Email, string FullName)
{
MySql.Data.MySqlClient.MySqlConnection con = null;
Database.Configuration.open(ref con);
string sql = @"
INSERT INTO `users`(`level`, `state`, `username`, `email`, `password`, `realname`)
VALUES (@level, @state, @username, @email, @password, @realname)";
var defaultLevel = Util.Config.Get().GetInt32("registration_default_authlevel", 2);
var defaultState = Util.Config.Get().GetInt32("registration_default_state", 0);
using (var rdr = new MySql.Data.MySqlClient.MySqlCommand(sql, con)) {
rdr.Parameters.AddWithValue("@level", defaultLevel);
rdr.Parameters.AddWithValue("@state", defaultState);
rdr.Parameters.AddWithValue("@username", Username);
rdr.Parameters.AddWithValue("@realname", FullName);
rdr.Parameters.AddWithValue("@email", Email);
rdr.Parameters.AddWithValue("@password", Password);
try {
rdr.ExecuteNonQuery(); // Let it throw a error so i can see if it works
} catch(Exception ex) {
throw;
return false;
}
} con.Close();
return true;
}
开发者ID:CallumCarmicheal,项目名称:AspDashboard,代码行数:31,代码来源:Register.cs
示例9: GetForecastFromDatabase
public CityForeCast[] GetForecastFromDatabase()
{
//SqlConnection connection = new SqlConnection(@"Data Source=(LocalDb)\MSSQLLocalDb;Initial Catalog=weatherForecast;Integrated Security=True;Pooling=False");
MySql.Data.MySqlClient.MySqlConnection connection = new MySql.Data.MySqlClient.MySqlConnection(@"Server=eu-cdbr-azure-west-c.cloudapp.net;Database=BDMeteo;Uid=b95badd8e1dbad;Pwd=bde4c7b6;Pooling=True");
connection.Open();
MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand("SELECT * FROM tablemeteo", connection);
MySql.Data.MySqlClient.MySqlDataReader reader = cmd.ExecuteReader();
List<CityForeCast> forecasts = new List<CityForeCast>();
while (reader.Read())
{
CityForeCast forecast = new CityForeCast();
forecast.City = (string)reader["City"];
forecast.description = (string)reader["Description"];
forecast.MaxTemp = (decimal)reader["Temperature"];
forecasts.Add(forecast);
}
reader.Close(); // Fermer le reader avant de fermer la connection
connection.Close();
return forecasts.ToArray();
//var ctx = new weatherForecastEntities();
//var forecast = ctx.Tables.Select(f => new CityForeCast()
//{
// City = f.City,
// description = f.Description,
// MaxTemp = (decimal)f.Temperature
//});
//return forecast;
}
开发者ID:Racuine,项目名称:MeteoApplication,代码行数:29,代码来源:dataAccess.cs
示例10: DeleteStock
private void DeleteStock(string stockToDelete)
{
msqlConnection = new MySql.Data.MySqlClient.MySqlConnection("server=localhost;user id=root;Password=technicise;database=sptdb;persist security info=False");
try
{ //define the command reference
MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
msqlCommand.Connection = msqlConnection;
msqlConnection.Open();
msqlCommand.CommandText = "DELETE FROM stock WHERE id= @vendorIdToDelete";
msqlCommand.Parameters.AddWithValue("@vendorIdToDelete", stockToDelete);
MySql.Data.MySqlClient.MySqlDataReader msqlReader = msqlCommand.ExecuteReader();
}
catch (Exception er)
{
MessageBox.Show(er.Message);
}
finally
{
//always close the connection
msqlConnection.Close();
}
}
开发者ID:shuiping150,项目名称:SalesPurchaseTracker,代码行数:26,代码来源:StockManagerWindow.xaml.cs
示例11: ConnectInsertTocustomerPaymentTable
public static void ConnectInsertTocustomerPaymentTable(CustomerPaymentData customerDataObject)
{
MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection();
try
{
//define the command reference
MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
//define the connection used by the command object
msqlCommand.Connection = msqlConnection;
FeedcustomerData(msqlCommand, customerDataObject);
}
catch (Exception er)
{
}
finally
{
msqlConnection.Close();
}
}
开发者ID:shuiping150,项目名称:SalesPurchaseTracker,代码行数:25,代码来源:DbInteraction.cs
示例12: EditSptPassword
public static void EditSptPassword(string passwordStr)
{
MySql.Data.MySqlClient.MySqlConnection msqlConnection = null;
msqlConnection = new MySql.Data.MySqlClient.MySqlConnection("server=localhost;user id=root;Password=technicise;database=sptdb;persist security info=False");
try
{ //define the command reference
MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
msqlCommand.Connection = msqlConnection;
msqlConnection.Open();
int idSptinfo = 1;
msqlCommand.CommandText = "UPDATE sptinfo SET password='" + passwordStr + "' WHERE id_sptinfo='" + idSptinfo + "'; ";
msqlCommand.ExecuteNonQuery();
}
catch (Exception er)
{
//MessageBox.Show(er.Message);
}
finally
{
//always close the connection
msqlConnection.Close();
}
}
开发者ID:shuiping150,项目名称:SalesPurchaseTracker,代码行数:26,代码来源:FetchSPTSettings.cs
示例13: AddAgent
public bool AddAgent(string name, string surname, string phone, string email, string password)
{
DatabaseManager dbManager = new DatabaseManager();
Cryptography crypto = new Cryptography();
MySql.Data.MySqlClient.MySqlCommand com = new MySql.Data.MySqlClient.MySqlCommand();
return (dbManager.NonReturnQuery("INSERT INTO Agent (Agent_Name , Agent_Surname, Agent_Phone, Agent_Email, Agent_Password) VALUES ('" + name + "','" + surname + "','" + phone + "','" + email + "','" + Cryptography.CreateHash(password).ToString() + "');"));
}
开发者ID:gpdiemelkman,项目名称:REII422_DesktopApp,代码行数:8,代码来源:AgentManager.cs
示例14: buttonOK_Click
private void buttonOK_Click(object sender, EventArgs e)
{
var conn = this.dataset.CreateSQLConnection();
conn.Open();
var query = new MySql.Data.MySqlClient.MySqlCommand(String.Format("call settlement('{0}')",dateTimePickerSettleDate.Value.ToString("yyyy-MM-dd")), conn);
query.ExecuteNonQuery();
this.Close();
}
开发者ID:Dalizi,项目名称:otc_platform_new,代码行数:8,代码来源:FormSettlement.cs
示例15: Execute
public static int Execute(string sql)
{
using (var conn = new MySql.Data.MySqlClient.MySqlConnection(ConnectString()))
{
conn.Open();
var cmd = new MySql.Data.MySqlClient.MySqlCommand(sql, conn);
int i = cmd.ExecuteNonQuery();
conn.Close();
return i;
}
}
开发者ID:gofixiao,项目名称:HYPDM_Pro,代码行数:11,代码来源:MySqlUtil.cs
示例16: GetRemoteDataTable
public static DataTable GetRemoteDataTable(string command, MySql.Data.MySqlClient.MySqlConnection msqConn)
{
DataTable rdt = new DataTable();
try
{
msqConn.Open();
MySql.Data.MySqlClient.MySqlCommand uploaderCmd = new MySql.Data.MySqlClient.MySqlCommand(command, msqConn);
MySql.Data.MySqlClient.MySqlDataReader onj = uploaderCmd.ExecuteReader();
bool colWasPerf = false;
int colIdx = 0;
List<object> rowValues = new List<object>();
foreach (System.Data.Common.DbDataRecord ro in onj)
{
try
{
// get fields
if (rdt.Columns.Count == 0 && !colWasPerf)
{
for (colIdx = 0; colIdx < ro.FieldCount; colIdx++)
rdt.Columns.Add(ro.GetName(colIdx));
colWasPerf = true;
}
}
catch { }
try
{
for (colIdx = 0; colIdx < ro.FieldCount; colIdx++)
rowValues.Add(ro[colIdx]);
}
catch { }
try
{
rdt.Rows.Add(rowValues.ToArray());
rowValues.Clear();
}
catch { }
}
onj.Close();
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
if (msqConn.State == System.Data.ConnectionState.Open)
msqConn.Close();
return rdt;
}
开发者ID:AndrewEastwood,项目名称:desktop,代码行数:53,代码来源:corelib.cs
示例17: SendClientMessage
public override void SendClientMessage(int Type, string MessageValue)
{
MySql.Data.MySqlClient.MySqlCommand command = new MySql.Data.MySqlClient.MySqlCommand();
command.CommandText = "INSERT INTO messages (SessionToken, Type, MessageValue, DateCreated) VALUES (@SessionToken, @Type, @MessageValue, @DateCreated);";
command.Parameters.AddWithValue("@SessionToken", Program.sessionToken);
command.Parameters.AddWithValue("@Type", Type);
command.Parameters.AddWithValue("@MessageValue", MessageValue);
command.Parameters.AddWithValue("@DateCreated", CommonCommunicator.UnixTime());
Database.Command(command);
command.Dispose();
}
开发者ID:AaronClaydon,项目名称:pocketSteam-archive,代码行数:12,代码来源:WebCommunicator.cs
示例18: ConnectFetchFromSaleslistTable
private void ConnectFetchFromSaleslistTable()
{
//define the connection reference and initialize it
msqlConnection = new MySql.Data.MySqlClient.MySqlConnection("server=localhost;user id=root;Password=technicise;database=sptdb;persist security info=False");
try
{
//define the command reference
MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
//define the connection used by the command object
msqlCommand.Connection = msqlConnection;
//open the connection
if (msqlConnection.State != System.Data.ConnectionState.Open)
msqlConnection.Open();
TimeSpan diff = (TimeSpan)(endDatePicker.SelectedDate - startDatePicker.SelectedDate);
msqlCommand.CommandText = "SELECT * FROM saleslist where date(saleslist.dateSales) >= DATE_SUB( @enddate, INTERVAL @diff DAY);";
msqlCommand.Parameters.AddWithValue("@enddate", endDatePicker.SelectedDate);
msqlCommand.Parameters.AddWithValue("@diff", diff.Days);
MySql.Data.MySqlClient.MySqlDataReader msqlReader = msqlCommand.ExecuteReader();
_salesDataCollection.Clear();
while (msqlReader.Read())
{
SalesData salesData = new SalesData();
salesData.customerId = msqlReader.GetString("customerId");
salesData.customerName = msqlReader.GetString("customerName"); //add
salesData.dateSales = msqlReader.GetDateTime("dateSales");
salesData.invoiceNo = msqlReader.GetString("invoiceNo");
salesData.payment = msqlReader.GetDouble("payment");
salesData.totalAmount = msqlReader.GetDouble("totalAmount");
//salesData.serialNo = (_salesDataCollection.Count + 1).ToString();
_salesDataCollection.Add(salesData);
}
}
catch (Exception er)
{
MessageBox.Show(er.Message);
}
finally
{
//always close the connection
msqlConnection.Close();
}
}
开发者ID:shuiping150,项目名称:SalesPurchaseTracker,代码行数:51,代码来源:SalesReportWindow.xaml.cs
示例19: ConnectFetchFromSaleslistTable
private void ConnectFetchFromSaleslistTable(string invoiceNumber)
{
//define the connection reference and initialize it
msqlConnection = new MySql.Data.MySqlClient.MySqlConnection("server=localhost;user id=root;Password=technicise;database=sptdb;persist security info=False");
try
{
//define the command reference
MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
//define the connection used by the command object
msqlCommand.Connection = msqlConnection;
//open the connection
if (msqlConnection.State != System.Data.ConnectionState.Open)
msqlConnection.Open();
msqlCommand.CommandText = "SELECT * FROM salesBilling WHERE invoiceNo = @invoiceNo;";
msqlCommand.Parameters.AddWithValue("@invoiceNo", invoiceNumber);
MySql.Data.MySqlClient.MySqlDataReader msqlReader = msqlCommand.ExecuteReader();
double totalVat = 0.0;
while (msqlReader.Read())
{
BillingData billedData = new BillingData();
billedData.amount = msqlReader.GetDouble("amount");
billedData.productName = msqlReader.GetString("description");
billedData.quantity = msqlReader.GetDouble("quantity");
billedData.vat = msqlReader.GetDouble("vat");
billedData.calVat = Convert.ToDouble(billedData.amount) * Convert.ToDouble(billedData.vat) * (.01); ;
totalVat += billedData.calVat;
billedData.rate = msqlReader.GetDouble("rate");
billedData.serialNo = billingItemListView.Items.Count + 1; //msqlReader.GetString("serialNo");
_billingCollection.Add(billedData);
vatAmount.Content = totalVat;
}
}
catch (Exception er)
{
MessageBox.Show(er.Message);
}
finally
{
//always close the connection
msqlConnection.Close();
}
}
开发者ID:shuiping150,项目名称:SalesPurchaseTracker,代码行数:50,代码来源:BillDetailsWindow.xaml.cs
示例20: LoadImage
public override Bitmap LoadImage(int image_id)
{
MySql.Data.MySqlClient.MySqlDataReader myData;
MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand();
string SQL;
byte[] rawData;
MemoryStream ms;
UInt32 FileSize;
Bitmap outImage;
SQL = "SELECT image_name, image_size, image_data FROM images WHERE id =";
SQL += image_id.ToString();
try
{
cmd.Connection = Connection;
cmd.CommandText = SQL;
myData = cmd.ExecuteReader();
if (!myData.HasRows)
throw new Exception("There are no blobs to save");
myData.Read();
FileSize = myData.GetUInt32(myData.GetOrdinal("image_size"));
rawData = new byte[FileSize];
myData.GetBytes(myData.GetOrdinal("image_data"), 0, rawData, 0, (Int32)FileSize);
ms = new MemoryStream(rawData);
outImage = new Bitmap(ms);
ms.Close();
ms.Dispose();
myData.Close();
myData.Dispose();
cmd.Dispose();
return outImage;
}
catch (MySql.Data.MySqlClient.MySqlException ex)
{
return null;
}
}
开发者ID:WebDaD,项目名称:StraTic,代码行数:49,代码来源:DB_MySQL.cs
注:本文中的MySql.Data.MySqlClient.MySqlCommand类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论