本文整理汇总了C#中IDatabase.CreateCommand方法的典型用法代码示例。如果您正苦于以下问题:C# IDatabase.CreateCommand方法的具体用法?C# IDatabase.CreateCommand怎么用?C# IDatabase.CreateCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDatabase
的用法示例。
在下文中一共展示了IDatabase.CreateCommand方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
示例3: Read
private List<Request> Read(DbDataReader reader, IDatabase db)
{
List<Request> requests = new List<Request>();
MedicineMapper medcat = MedicineMapper.GetInstance();
while (reader.Read())
{
Prescription er = new Prescription();
er.Id = reader.GetInt32(0);
er.Created = reader.GetDateTime(1);
DbCommand command = db.CreateCommand(sqlSELECTMEDICINE);
command.Parameters.Add(db.CreateParameter("@id", "int"));
command.Parameters["@id"].Value = er.Id;
DbDataReader medicines = db.Select(command);
er.Medicines = this.ReadMedicines(medicines, medcat);
medicines.Close();
requests.Add(er);
}
return requests;
}
示例4: ReadAllergens
private List<string> ReadAllergens(Medicine m, IDatabase db)
{
DbCommand command = db.CreateCommand(sqlSELECTALLERGENS);
command.Parameters.Add(db.CreateParameter("@id", "int"));
command.Parameters["@id"].Value = m.Id;
DbDataReader areader = db.Select(command);
List<string> allergens = new List<string>();
while (areader.Read())
{
allergens.Add(areader.GetString(0));
}
areader.Close();
return allergens;
}
示例5: 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;
}