本文整理汇总了C#中Connection.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.Execute方法的具体用法?C# Connection.Execute怎么用?C# Connection.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection.Execute方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
try
{
conn = new Connection();
string connectionstring = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString;
conn.Open(connectionstring);
Message = Request["Message"];
UserIPAddress = GetIPAddress();
//For Demo
// UserIPAddress = "192.168.1.12";
Rs1 = new Recordset();
sql1 = "Select Station From Station Where IPAddress ='" + UserIPAddress + "'";
Rs1 = conn.Execute(sql1);
if (!(Rs1.Eof))
{
StationID = Rs1.Fields["Station"].Value;
Session["StationID"] = StationID;
conn.Close();
}
else
{
Alert = "編號未設置, 請提供此電腦的 IP 地址 [ " + UserIPAddress + " ] 給系統管理員";
}
}
catch (Exception ex)
{
}
}
示例2: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
conn = new Connection();
string connectionstring = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString;
conn.Open(connectionstring);
//For Demo
UserIPAddress = GetIPAddress();
//UserIPAddress = Request.ServerVariables["REMOTE_ADDR"];
Rs1 = new Recordset();
sql1 = "Select Station From Station Where IPAddress ='" + UserIPAddress + "'";
Rs1 = conn.Execute(sql1);
StationID = Rs1.Fields["Station"].Value;
UserID = Session["UserID"];
SecLevel = Session["SecLevel"];
CarPlate = Request["CarPlate"];
ProductType = Request["ProductType"];
Message = "";
if (Convert.ToString(SecLevel) == "")
{
Response.Redirect("Default.aspx");
}
Session.Add("SecLevel", SecLevel);
Session.Add("UserID", UserID);
Session.Add("StationID", StationID);
}
示例3: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
try
{
conn = new Connection();
string connectionstring = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString;
conn.Open(connectionstring);
UserID = (Request["UserID"]).Trim();
Level = (Request["SecLevel"]).Trim();
StationID = (Request["StationID"]).Trim();
UserID = (Request["UserID"]).TrimEnd();
SDay = Request["SDay"];
SMonth = Request["SMonth"];
SYear = Request["SYear"];
NDay = Request["NDay"];
NMonth = Request["NMonth"];
NYear = Request["NYear"];
// Search_Date = Strings.FormatDateTime(new DateTime(Convert.ToInt32(SYear), Convert.ToInt32(SMonth), Convert.ToInt32(SDay)), (DateFormat)2);
//Search_NDate = Strings.FormatDateTime(new DateTime(Convert.ToInt32(NYear), Convert.ToInt32(NMonth), Convert.ToInt32(NDay)), (DateFormat)2);
Search_Date = SDay + "/" + SMonth + "/" + SYear;
Search_NDate = NDay + "/" + NMonth + "/" + NYear;
fsql = "select * from MasterCoupon where RequestedID = " + StationID +
" and Present_Date >= Convert(datetime, '" + Search_Date + "', 105) " +
" and Present_Date < DATEADD(dd,DATEDIFF(dd,0, Convert(datetime, '" + Search_NDate + "', 105)),0) + 1 " +
" order by id desc";
//response.write fsql
//response.end
RS1 = conn.Execute(fsql);
//Today = Strings.FormatDateTime(DateTime.Now, (DateFormat)2);
Today = DateTime.Now.ToString("dd-MM-yyyy");
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=§¨é¬ö¿ý(" + Today + ").pdf");
// Write_CSV_From_Recordset(RS1);
ExportToPDF(RS1, true, StationID);
}
catch (Exception ex)
{
}
}
示例4: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
conn = new Connection();
string connectionstring = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString;
conn.Open(connectionstring);
UserIPAddress = GetIPAddress();
//For Demo
//UserIPAddress = "192.168.1.12";
//UserIPAddress = Request.ServerVariables["REMOTE_ADDR"];
Rs1 = new Recordset();
sql1 = "Select Station , LoginUser From Station Where IPAddress ='" + UserIPAddress + "'";
Rs1 = conn.Execute(sql1);
StationID = Rs1.Fields["Station"].Value;
UserID = Rs1.Fields["LoginUser"].Value;
CarPlate = Request["CarPlate"];
ProductType = Request["ProductType"];
Message = "";
}
示例5: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
conn = new Connection();
string connectionstring = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString;
conn.Open(connectionstring);
UserIPAddress = GetIPAddress();
//For Demo
//UserIPAddress = "192.168.1.12";
//UserIPAddress = Request.ServerVariables["REMOTE_ADDR"];
Rs1 = new Recordset();
sql1 = "Select * From Station s Left Join CVSUser u on ";
sql1 = sql1 + " s.LoginUser = u.UserName Where IPAddress ='" + UserIPAddress + "'";
Rs1 = conn.Execute(sql1);
StationID = (Rs1.Fields["Station"].Value).ToString().Trim();
UserID = (Rs1.Fields["LoginUser"].Value).ToString().Trim();
SecLevel = (Rs1.Fields["SecLevel"].Value).ToString().Trim();
if (UserID == "")
{
Response.Redirect("Default.aspx");
}
Message = Request["Message"];
Coupon_Number = Request["Coupon_Number"];
Car_No = Request["Car_No"];
Face_Value = Request["Face_Value"];
Period = Request["Period"];
//search by date
if (Request["SDay"] != null)
{
SDay = Request["SDay"];
SMonth = Request["SMonth"];
SYear = Request["SYear"];
}
else
{
SDay = Convert.ToString(DateTime.Now.Day);
SMonth = Convert.ToString(DateTime.Now.Month);
SYear = Convert.ToString(DateTime.Now.Year);
}
if (Request["NDay"] != null)
{
NDay = Request["NDay"];
NMonth = Request["NMonth"];
NYear = Request["NYear"];
}
else
{
NDay = Convert.ToString(DateTime.Now.Day);
NMonth = Convert.ToString(DateTime.Now.Month);
NYear = Convert.ToString(DateTime.Now.Year);
}
//Search_Date = Formatdatetime(DateSerial(SYear, SMonth, SDay),2)
//Search_NDate = Formatdatetime(DateSerial(NYear, NMonth, NDay),2)
Search_Date = SDay + "/" + SMonth + "/" + SYear;
Search_NDate = NDay + "/" + NMonth + "/" + NYear;
//Response.write search_date
//response.write SecLevel & "<br>"
//response.write UserID
if (Request.Form["pageid"] != null)
pageid = (Request.Form["pageid"]).Trim();
if (pageid == "")
{
pageid = "1";
}
if (Request.Form["Barcode"] != null)
{
Barcode = (Request.Form["Barcode"]).Trim().Replace("%", "%");
Barcode = Barcode.Replace("'", "''");
if (Barcode.Length == 15)
{
Face_Value = Barcode.Substring(0, 3);
Coupon_Type = Barcode.Substring(5 - 1, 2);
Coupon_batch = Barcode.Substring(7 - 1, 3);
Coupon_Number = Barcode.Substring(10 - 1, 6);
}
}
fsql = "select * from MasterCoupon where RequestedID = " + Convert.ToString(StationID);
//Search Coupon Number
//********************
if (Barcode != "")
{
if (Barcode.Length == 15)
{
fsql = fsql + " and Coupon_Number = '" + Coupon_Number + "'";
fsql = fsql + " and Face_Value = '" + Face_Value + "'";
fsql = fsql + " and Coupon_Type = '" + Coupon_Type + "'";
fsql = fsql + " and Coupon_Batch = '" + Coupon_batch + "'";
}
else
{
fsql = fsql + " and Coupon_Number LIKE '%" + Barcode + "%' ";
}
}
fsql = fsql + " and Present_Date >= Convert(datetime, '" + Convert.ToString(Search_Date) + "', 105) ";
fsql = fsql + " and Present_Date < DATEADD(dd,DATEDIFF(dd,0, Convert(datetime, '" + Convert.ToString(Search_NDate) + "', 105)),0) + 1 ";
//By UserID
if (Convert.ToString(SecLevel).Trim() == "1")
//.........这里部分代码省略.........
示例6: Execute
internal void Execute (HyenaSqliteConnection hconnection, Connection connection)
{
if (finished) {
throw new Exception ("Command is already set to finished; result needs to be claimed before command can be rerun");
}
execution_exception = null;
result = null;
int execution_ms = 0;
string command_text = null;
try {
command_text = CurrentSqlText;
ticks = System.Environment.TickCount;
switch (CommandType) {
case HyenaCommandType.Reader:
using (var reader = connection.Query (command_text)) {
result = new ArrayDataReader (reader, command_text);
}
break;
case HyenaCommandType.Scalar:
result = connection.Query<object> (command_text);
break;
case HyenaCommandType.Execute:
default:
connection.Execute (command_text);
result = connection.LastInsertRowId;
break;
}
execution_ms = System.Environment.TickCount - ticks;
if (log_all) {
Log.DebugFormat ("Executed in {0}ms {1}", execution_ms, command_text);
} else if (Log.Debugging && execution_ms > 500) {
Log.WarningFormat ("Executed in {0}ms {1}", execution_ms, command_text);
}
} catch (Exception e) {
Log.DebugFormat ("Exception executing command: {0}", command_text ?? command);
Log.Exception (e);
execution_exception = e;
}
// capture the text
string raise_text = null;
if (raise_command_executed && execution_ms >= raise_command_executed_threshold_ms) {
raise_text = Text;
}
finished_event.Reset ();
finished = true;
if (raise_command_executed && execution_ms >= raise_command_executed_threshold_ms) {
var handler = CommandExecuted;
if (handler != null) {
// Don't raise this on this thread; this thread is dedicated for use by the db connection
ThreadAssist.ProxyToMain (delegate {
handler (this, new CommandExecutedArgs (raise_text, execution_ms));
});
}
}
}