本文整理汇总了C#中Microsoft.Practices.EnterpriseLibrary.Data.Database.ExecuteScalar方法的典型用法代码示例。如果您正苦于以下问题:C# Database.ExecuteScalar方法的具体用法?C# Database.ExecuteScalar怎么用?C# Database.ExecuteScalar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Practices.EnterpriseLibrary.Data.Database
的用法示例。
在下文中一共展示了Database.ExecuteScalar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Insert
protected int Insert(BaseTable nesne, DbCommand dbComm, DbTransaction dbTransaction, Database db)
{
//YetkiKullanici ui = (YetkiKullanici)HttpContext.Current.Session["YetkiKullanici"];
//if (ui == null)
//{
// ui = new YetkiKullanici();
// ui.Tckimlikno = "Everyone";
// ui.Ip = HttpContext.Current.Request.UserHostAddress;
//}
int sonuc = 0;
string geriDeger = "";
if (dbTransaction == null) geriDeger = db.ExecuteScalar(dbComm).ToString();
else geriDeger = db.ExecuteScalar(dbComm, dbTransaction).ToString();
//if (ConfigurationSettings.AppSettings.Get("DBLOG_AKTIF") != null &&
// ConfigurationSettings.AppSettings.Get("DBLOG_AKTIF") == "E")
//{
// try
// {
// int.TryParse(geriDeger, out sonuc);
// GenDbLog log = new GenDbLog();
// log.Tckimlikno = ui.Tckimlikno;
// log.KullaniciIp = ui.Ip;
// log.Tablo = nesne.GetName();
// log.KayitId = sonuc;
// log.Kayit = nesne.ToString();
// log.Tarih = DateTime.Now;
// log.YapilanIslem = "I";
// InsertLog(log, dbTransaction, db);
// }
// catch (Exception ex) { }
//}
bool snc = int.TryParse(geriDeger, out sonuc);
return sonuc;
}
示例2: Insert
public static int Insert(Database db, CapturePicture ocapturePicture)
{
StringBuilder sbField = new StringBuilder();
StringBuilder sbValue = new StringBuilder();
sbField.Append("INSERT INTO [CapturePicture](");
sbValue.Append("values (");
//sbField.Append("[PictureID]");
//sbValue.AppendFormat("'{0}'", ocapturePicture.PictureID);
sbField.Append("[CameraID]");
sbValue.AppendFormat("{0}", ocapturePicture.CameraID);
sbField.Append(",[Datetime]");
//sbValue.AppendFormat(",'{0}'", ocapturePicture.Datetime);
sbValue.AppendFormat(",'{0}'", ocapturePicture.Datetime);
sbField.Append(",[FilePath])");
sbValue.AppendFormat(",'{0}')", ocapturePicture.FilePath);
string cmdText = sbField.ToString() + " " + sbValue.ToString();
try
{
cmdText = cmdText.Replace("\r\n", "");
db.ExecuteNonQuery(CommandType.Text, cmdText);
//string cmdText2 = "select max(PictureID) from CapturePicture";
//return int.Parse(db.ExecuteScalar(CommandType.Text, cmdText2).ToString());
int id = int.Parse(db.ExecuteScalar(CommandType.Text, "SELECT ident_current('CapturePicture')").ToString());
return id;
}
catch (Exception ex)
{
throw ex;
}
}
示例3: Insert
public static int Insert(Database db, REct oRect)
{
StringBuilder sbField = new StringBuilder();
StringBuilder sbValue = new StringBuilder();
sbField.Append("INSERT INTO [REct](");
sbValue.Append("values (");
//sbField.Append("[RectID]");
//sbValue.AppendFormat("'{0}'", oRect.RectID);
sbField.Append("[X]");
sbValue.AppendFormat("{0}", oRect.X);
sbField.Append(",[Y]");
sbValue.AppendFormat(",{0}", oRect.Y);
sbField.Append(",[W]");
sbValue.AppendFormat(",{0}", oRect.W);
sbField.Append(",[H])");
sbValue.AppendFormat(",{0})", oRect.H);
string cmdText = sbField.ToString() + " " + sbValue.ToString();
try
{
cmdText = cmdText.Replace("\r\n", "");
db.ExecuteNonQuery(CommandType.Text, cmdText);
int id = int.Parse(db.ExecuteScalar(CommandType.Text, "SELECT ident_current('REct')").ToString());
return id;
}
catch (Exception ex)
{
throw ex;
}
}
示例4: Insert
public static int Insert(Database db, Track oTrack)
{
StringBuilder sbField = new StringBuilder();
StringBuilder sbValue = new StringBuilder();
sbField.Append("INSERT INTO [Track](");
sbValue.Append("values (");
//sbField.Append("[Id]");
//sbValue.AppendFormat("'{0}'", oTrack.Id);
sbField.Append("[REct])");
sbValue.AppendFormat("'{0}')", oTrack.REct);
string cmdText = sbField.ToString() + " " + sbValue.ToString();
try
{
cmdText = cmdText.Replace("\r\n", "");
db.ExecuteNonQuery(CommandType.Text, cmdText);
int id = int.Parse(db.ExecuteScalar(CommandType.Text, "SELECT ident_current('Track')").ToString());
return id;
}
catch (Exception ex)
{
throw ex;
}
}
示例5: Insert
public static int Insert(Database db, EventRect oEventRect)
{
StringBuilder sbField = new StringBuilder();
StringBuilder sbValue = new StringBuilder();
sbField.Append("INSERT INTO [EvenRectInfo](");
sbValue.Append("values (");
//sbField.Append("[FaceID]");
//sbValue.AppendFormat("'{0}'", oFace.FaceID);
sbField.Append("[x]");
sbValue.AppendFormat("{0}", oEventRect.x);
sbField.Append(",[y]");
sbValue.AppendFormat(",{0}", oEventRect.y);
sbField.Append(",[w]");
sbValue.AppendFormat(",{0}", oEventRect.w);
sbField.Append(",[h]");
sbValue.AppendFormat(",{0}", oEventRect.h);
sbField.Append(",[ObjectId])");
sbValue.AppendFormat(",{0})", oEventRect.ObjectId);
string cmdText = sbField.ToString() + " " + sbValue.ToString();
try
{
cmdText = cmdText.Replace("\r\n", "");
db.ExecuteNonQuery(CommandType.Text, cmdText);
int id = int.Parse(db.ExecuteScalar(CommandType.Text, "SELECT ident_current('EventRectInfo')").ToString());
return id;
}
catch (Exception ex)
{
throw ex;
}
}
示例6: IsExistRow
private static bool IsExistRow(Database db,string name)
{
string cmdText = string.Format("select count(*) from systemParameter where Name='{0}';", name);
try
{
return int.Parse(db.ExecuteScalar(CommandType.Text, cmdText).ToString())>0;
}
catch (Exception ex)
{
throw ex;
}
}
示例7: GetMaxDisplayChannelId
public static int GetMaxDisplayChannelId(Database db)
{
string cmdText = "select max(DisplayChannelId) from displayChannelInfo";
try
{
return int.Parse(db.ExecuteScalar(CommandType.Text, cmdText).ToString());
}
catch (Exception ex)
{
throw ex;
}
}
示例8: IsTaskExisted
public static bool IsTaskExisted(Database db, int taskId)
{
string cmdText = string.Format("select count(*) from TaskInfo where TaskId={0}",taskId);
try
{
return int.Parse(db.ExecuteScalar(CommandType.Text, cmdText).ToString())>0;
}
catch (Exception ex)
{
throw ex;
}
}
示例9: IsExistCapturePicture
public static bool IsExistCapturePicture(Database db, int id, DateTime dt)
{
string cmdText = string.Format("select count(*) from CapturePicture where CameraID={0} and Datetime={1}", id, dt);
try
{
return int.Parse(db.ExecuteScalar(CommandType.Text, cmdText).ToString()) > 0;
}
catch (Exception ex)
{
return false;
}
}
示例10: GetMaxGroupSwitchGroupId
public static int GetMaxGroupSwitchGroupId(Database db)
{
string cmdText = "select max(Id) from GroupSwitchGroup";
try
{
return int.Parse(db.ExecuteScalar(CommandType.Text, cmdText).ToString());
}
catch (Exception ex)
{
throw ex;
}
}
示例11: GetMaxSystemLogId
public static int GetMaxSystemLogId(Database db)
{
string cmdText = "select max(Id) from OperateLog";
try
{
return int.Parse(db.ExecuteScalar(CommandType.Text, cmdText).ToString());
}
catch (Exception ex)
{
throw ex;
}
}
示例12: GetMaxUserId
public static int GetMaxUserId(Database db)
{
string cmdText = "select max([UserId]) from [UserInfo]";
try
{
return int.Parse(db.ExecuteScalar(CommandType.Text, cmdText).ToString());
}
catch (Exception ex)
{
throw ex;
}
}
示例13: GetCurrentDateTime
internal static DateTime GetCurrentDateTime(Database db)
{
try
{
using (DbCommand cmd = db.GetSqlStringCommand(Resources.GetDatabaseCurrentDateTime))
{
return (DateTime)db.ExecuteScalar(cmd);
}
}
catch (Exception e)
{
AssistLogger.Log<ExceptionHolder>(e);
return DateTime.Now;
}
}
示例14: GetEventRectCustomQuantity
public static int GetEventRectCustomQuantity(Database db, int objectid)
{
string cmdText = string.Format(
"select count(distinct EventRectInfo.EventRectId) " +
"from EventRectInfo " +
"where EventRectInfo.ObjectId={0}",objectid);
try
{
return int.Parse(db.ExecuteScalar(CommandType.Text, cmdText).ToString());
}
catch (Exception ex)
{
throw ex;
}
}
示例15: GetEventCustomQuantity
public static int GetEventCustomQuantity(Database db, string str)
{
str = str.Replace("''", "'");
string cmdText = string.Format(
"select count(distinct EventInfo.EventId) " +
"from EventInfo,CapturePicture,VideoInfo " +
"where EventInfo.PictureId=CapturePicture.PictureId and " +
"CapturePicture.CameraId = VideoInfo.CameraId and (CapturePicture.[DateTime] between VideoInfo.CaptureTimeBegin and VideoInfo.CaptureTimeEnd) {0};", str);
try
{
return int.Parse(db.ExecuteScalar(CommandType.Text, cmdText).ToString());
}
catch (Exception ex)
{
throw ex;
}
}