本文整理汇总了C#中IDatabase.ExecuteNonQuery方法的典型用法代码示例。如果您正苦于以下问题:C# IDatabase.ExecuteNonQuery方法的具体用法?C# IDatabase.ExecuteNonQuery怎么用?C# IDatabase.ExecuteNonQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDatabase
的用法示例。
在下文中一共展示了IDatabase.ExecuteNonQuery方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: runDbCommands
protected void runDbCommands(IDatabase db, IList<string> sqls)
{
foreach (string sql in sqls) {
DbCommand cmd = db.CreateCommand(sql);
db.ExecuteNonQuery(cmd);
}
}
示例2: SaveDataToDatabase
public bool SaveDataToDatabase(IDatabase database)
{
return database.ExecuteNonQuery(
"UPDATE characters SET " +
"level=" + Level + ", " +
"map_id=" + Map + ", " +
"pos_x=" + Position.X + ", " +
"pos_y=" + Position.Y + ", " +
"pos_z=" + Position.Z + ", " +
"rot_x=" + Rotation.X + ", " +
"rot_y=" + Rotation.Y + ", " +
"rot_z=" + Rotation.Z + " " +
"WHERE character_id=" + Id) == 1;
}
示例3: UpdateLastInfo
public bool UpdateLastInfo(IDatabase database, NetworkClient client)
{
var t2 = 0;
DllImport.Other.time(ref t2);
return database.ExecuteNonQuery("UPDATE accounts SET " +
"last_connection=" + t2 +
", last_ip='" + client.IpAddress + "'" +
"WHERE account_id=" + Id) == 1;
}
示例4: AddResults
private void AddResults(int id, string results, DateTime processed, IDatabase db)
{
DbCommand command = db.CreateCommand(sqlADDRESULTS);
command.Parameters.Add(db.CreateParameter("@results", "varchar", results.Length));
command.Parameters["@results"].Value = results;
command.Parameters.Add(db.CreateParameter("@processed", "datetime"));
command.Parameters["@processed"].Value = processed;
db.ExecuteNonQuery(command);
}
示例5: MigrateTable
private static void MigrateTable(string table, IDatabase from, IDatabase to)
{
var count = 0;
var sql = string.Format("select * from {0}", table);
from.ExecuteDataReader(sql, null, dr => {
var item = new Dictionary<string, object>();
foreach (var i in Enumerable.Range(0, dr.FieldCount)) {
var fieldName = dr.GetName(i);
var fieldValue = dr[i];
item.Add(fieldName, fieldValue);
}
var insertSql = string.Format(@"insert into {0}({1})values({2})",
table,
string.Join(", ", item.Keys.Select(p => string.Format(@"{0}", p))),
string.Join(", ", item.Keys.Select(p => "@" + p)));
to.ExecuteNonQuery(insertSql, item);
if (count++ % 1000 == 0)
Console.Write(".");
});
}
示例6: CreateTable
protected internal override void CreateTable(IDatabase db, string tableName, Type entityType)
{
if (entityType == typeof(Order))
{
// todo:根据模型自动创建表
db.ExecuteNonQuery(String.Format(@"
CREATE TABLE [{0}](
[OrderID] [int] IDENTITY(1,1) NOT NULL,
[Title] [nvarchar](32) NOT NULL,
[CustomerName] [nvarchar](64) NOT NULL,
[TS] [timestamp] NOT NULL,
PRIMARY KEY CLUSTERED
(
[OrderID] ASC
)
) ON [PRIMARY]", tableName));
}
}
示例7: DeleteRowFromTableCalendar
internal static void DeleteRowFromTableCalendar(IDatabase db, string id, string name)
{
string strCommand = "Delete From lichhen";
strCommand += " Where Idpatient='" + id + "' AND Namepatient='" + name + "';";
//MySqlCommand comm = new MySqlCommand(strCommand, conn);
db.ExecuteNonQuery(strCommand, null);
}
示例8: UpdateRowToTableCalendar
public static void UpdateRowToTableCalendar(IDatabase db, string nameOfTable, List<string> nameOfColumns,
List<string> values, string id, string Username)
{
string strCommand = BuildFirstPartUpdateQuery(nameOfTable, nameOfColumns, values);
strCommand += " Where IdCalendar='" + id + "' AND Username='" + Username + "';";
//MySqlCommand comm = new MySqlCommand(strCommand, conn);
db.ExecuteNonQuery(strCommand, null);
}
示例9: DeleteRowToTableCalendar
public static void DeleteRowToTableCalendar(IDatabase db, string nameOfTable, string id, string Username)
{
string strCommand = "Delete From " + nameOfTable;
strCommand += " Where IdCalendar='" + id + "' AND Username='" + Username + "';";
//MySqlCommand comm = new MySqlCommand(strCommand, conn);
db.ExecuteNonQuery(strCommand, null);
}
示例10: DeleteRowFromTablelistpatienttoday
public static void DeleteRowFromTablelistpatienttoday(IDatabase db, string id, string name)
{
string strCommand = "Delete From listpatienttoday";
strCommand += " Where Id='" + id + "' AND Name='" + name + "';";
//MySqlCommand comm = new MySqlCommand(strCommand, conn);
db.ExecuteNonQuery(strCommand, null);
}
示例11: UpdateRowToTableMedicine
internal static void UpdateRowToTableMedicine(IDatabase db, string p, int offset, string p_2)
{
//get current number of medicine in store
string strCommand = "Select Count from medicine where Id = " + p_2;
DbDataReader reader = db.ExecuteReader(strCommand, null) as DbDataReader;
reader.Read();
if (reader.HasRows)
{
int numberInStore = int.Parse(reader[DatabaseContants.medicine.Count].ToString());
int numberWillBe = numberInStore - offset;
reader.Close();
strCommand = "Update Medicine Set Count =" + numberWillBe.ToString() + " Where Id =" + p_2;
db.ExecuteNonQuery(strCommand, null);
}
else
{
reader.Close();
}
}
示例12: UpdateRowToTableDoanhThu
internal static void UpdateRowToTableDoanhThu(IDatabase db, string nameOfTable, List<string> columnsDoanhThu, List<string> valuesDoanhThu, string p_2)
{
string strCommand = BuildFirstPartUpdateQuery(nameOfTable, columnsDoanhThu, valuesDoanhThu);
strCommand += " Where Idpatient='" + p_2 + "'And time=" + ConvertToSqlString(DateTime.Now.ToString("yyyy-MM-dd")) + ";";
//MySqlCommand comm = new MySqlCommand(strCommand, conn);
db.ExecuteNonQuery(strCommand, null);
}
示例13: InsertMedicines
private int InsertMedicines(Prescription p, IDatabase db)
{
int added = 0;
DbCommand command;
foreach (Medicine m in p.Medicines)
{
command = db.CreateCommand(sqlINSERTMEDICINE);
command.Parameters.Add(db.CreateParameter("@id", "int"));
command.Parameters["@id"].Value = p.Id;
command.Parameters.Add(db.CreateParameter("@medicineid", "int"));
command.Parameters["@medicineid"].Value = m.Id;
added += db.ExecuteNonQuery(command);
}
return added;
}
示例14: UpdateLastInfo
public bool UpdateLastInfo(IDatabase database, NetworkClient client)
{
var t2 = 0;
DllImport.Other.time(ref t2);
return database.ExecuteNonQuery("UPDATE characters SET " +
"last_connection=" + t2 + " " +
"WHERE character_id=" + Id) == 1;
}