本文介绍了如何调试Web表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 限时删除!! hi i已经开发了一个Web应用程序,当我通过设置run as start up运行时,有一个Web表单DataTransaction.aspx 浏览器观察 localhost:3038 / DataTransaction.aspx ----->达到这个罚款。 但我想用url跟踪(通过保持断点): localhost:3038 / DataTransaction.aspx?MID = mach1&& CNUM = c1& AMT = 1000& TOT = 01022014112233& ; UPWD = op1& TT = 1 这里是代码背后的表格代码:< pre lang = c#>使用System; 使用 System.Collections.Generic; 使用 System.Linq; 使用 System.Web; 使用 System.Web.UI; 使用 System.Web.UI.WebControls; 使用 MySql.Data.MySqlClient; 使用 System.Web.Configuration; 命名空间 Online_Billing_System { public partial class DataTransaction:System.Web.UI.Page { 字符串 ConnectionString = WebConfigurationManager.ConnectionStrings [ myConnectionString]。的ToString(); bool found = false ; 字符串 memberid,name,phonenumber; decimal openbal,due; 受保护 void Page_Load( object sender,EventArgs e) { String machineid = Request.QueryString [ MID]; 字符串 cardid = Request.QueryString [ CNUM]; decimal paidamount = Convert.ToDecimal(Request.QueryString [ AMT]); 字符串 paiddate = Request.QueryString [ TOT]; 字符串 operatorid = Request.QueryString [ UPWD]; if (machineid!= null && cardid!= null && paidamount!= 0 && paiddate!= null && operatorid!= null ) { if (Convert.ToInt32(Request.QueryString [ TT] )== 1 ) { 使用(MySqlConnection con = new MySqlConnection(ConnectionString)) { // 运营商ID是否存在 S tring browseroperatorid = Request.QueryString [ UPWD]。ToString(); 字符串 query = 从运算符中选择operator_id ; MySqlCommand command = new MySqlCommand(query,con); con.Open(); 使用(MySqlDataReader rdr = command.ExecuteReader()) { while (rdr.Read()) { String dboperatorid = rdr [ operator_id]。ToString(); if (dboperatorid.Equals(browseroperatorid)) { found = 真; break ; } } } 如果(找到== true ) { // 如果运营商ID存在,则根据卡ID从管理员处获取详细信息 字符串 selectquery = select * from admin其中card_id =' + cardid + '; MySqlCommand command1 = new MySqlCommand(selectquery,con); 使用(MySqlDataReader rdr = command1.ExecuteReader()) { if (rdr.Read()) { memberid = rdr [ member_id ]的ToString(); name = rdr [ name]。ToString(); phonenumber = rdr [ phone_number]。ToString(); openbal = Convert.ToDecimal(rdr [ opening_balance]。ToString()); 到期= openbal - paidamount; } // 卡片ID不存在 else Response.Write( $ TS = 2 #); } // 将新记录插入交易 字符串 insertquery = insert into transaction(machine_id,operator_id,member_id,card_id,name,paid_amount,due_amount,paid_date,phone_number)值(@ machineid,@ operatorid,@ memberid,@ cardid,@ name,@ paidamount,@ dueamount,@ paiddate,@ phone) ; MySqlCommand command2 = new MySqlCommand(insertquery,con); command2.Parameters.AddWithValue( @ machineid,machineid); command2.Parameters.AddWithValue( @ operatorid,operatorid); command2.Parameters.AddWithValue( @ memberid,memberid); command2.Parameters.AddWithValue( @ cardid,cardid); command2.Parameters.AddWithValue( @ name,name); command2.Parameters.AddWithValue( @ paidamount,paidamount); command2.Parameters.AddWithValue( @ dueamount,due); if (paiddate.Length == 14 ) { string format = ddMMyyyyHmmss; DateTime dateTime = DateTime.ParseExact(paiddate,format, System.Globalization.CultureInfo.InvariantCulture); String result = dateTime.ToString( yyyy-MM-dd H:mm:ss); command2.Parameters.AddWithValue( @ paiddate,result); } 其他 // 如果日期不包含14位数,则无效的交易。 { Response.Write( $ TS = 2#); } command2.Parameters.AddWithValue( @ phone,phonenumber) ; command2.ExecuteNonQuery(); Response.Write( $ AMT =' + paidamount + '| BAL =' + due + '| TS = 1#); // 更新管理员的到期金额 字符串 updatequery = update admin set opening_balance =' + due + '其中card_id =' + cardid + '; MySqlCommand command3 = new MySqlCommand(updatequery,con); command3.ExecuteNonQuery(); } // 无效的运营商ID else Response.Write( $ TS = 3# ); } } 其他 if (转换.ToInt32(Request.QueryString [ TT])== 2 ) { 使用(MySqlConnection con = new MySqlConnection(ConnectionString)) { String browseroperatorid = Request.QueryString [ UPWD]。ToString(); 字符串 query = 从运算符中选择operator_id ; MySqlCommand command = new MySqlCommand(query,con); con.Open(); 使用(MySqlDataReader rdr = command.ExecuteReader()) { while (rdr.Read()) { String dboperatorid = rdr [ operator_id]。ToString(); if (dboperatorid.Equals(browseroperatorid)) { found = 真; break ; } } } 如果(找到== true ) { String query1 = 从admin中选择opening_balance,其中card_id =' + cardid + '; MySqlCommand command1 = new MySqlCommand(query1,con); 使用(MySqlDataReader rdr = command.ExecuteReader()) { if (rdr.Read()) { String bal = rdr [ opening_balance]。ToString(); Response.Write( $ BAL =' + bal + '| TS = 1#); } 其他 // 卡片ID不存在 Response.Write( $ TS = 2 #); } } 其他 // 运算符ID不存在 Response.Write( $ TS = 3#); } } 其他 if (Convert.ToInt32(Request.QueryString [ TT])== 3 ) { 使用(MySqlConnection con = new MySqlConnection(ConnectionString)) { String browseroperatorid = Request.QueryString [ UPWD]。ToString(); 字符串 query = 从运算符中选择operator_id ; MySqlCommand command = new MySqlCommand(query,con); con.Open(); 使用(MySqlDataReader rdr = command.ExecuteReader()) { while (rdr.Read()) { String dboperatorid = rdr [ operator_id]。ToString(); if (dboperatorid.Equals(browseroperatorid)) { found = 真; break ; } } } 如果(找到== true ) { } } } // 无效交易 } else Response.Write( $ TS = 2#); } } } 如何检查。解决方案 TS = 2#); } // 将新记录插入到交易中 String insertquery = 插入到事务中(machine_id,operator_id,member_id,card_id,name,paid_amount,due_amount,paid_date ,PHONE_NUMBER)值(@设备ID,@ operatorid,@ MEMBERID,@ CardId中,@名称,@ paidamount,@ dueamount,@ paiddate,@电话) ; 的MySqlCommand命令2 = ; DateTime dateTime = DateTime.ParseExact(paiddate,format, System.Globalization.CultureInfo.InvariantCulture); String result = dateTime.ToString( yyyy-MM-dd H:mm:ss); command2.Parameters.AddWithValue( @ paiddate,result); } 其他 // 如果日期不包含14位数,则无效的交易。 { Response.Write( TS = 2#); } command2.Parameters.AddWithValue( @ phone,phonenumber) ; command2.ExecuteNonQuery(); Response.Write( AMT = ' + paidamount + '| BAL =' + due + '| TS = 1#); // 更新管理员的到期金额 字符串 updatequery = update admin set opening_balance =' + due + '其中card_id =' + cardid + '; MySqlCommand command3 = new MySqlCommand(updatequery,con); command3.ExecuteNonQuery(); } // 无效的运营商ID else Response.Write( hii have developed a web application,having a web form DataTransaction.aspxwhen i run this by setting "run as start up" in browser am observinglocalhost:3038/DataTransaction.aspx----->upto this fine.but i want to trace (by keeping break points) with url:localhost:3038/DataTransaction.aspx?MID=mach1&&CNUM=c1&AMT=1000&TOT=01022014112233&UPWD=op1&TT=1here is my form code behind code:<pre lang="c#">using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using MySql.Data.MySqlClient;using System.Web.Configuration;namespace Online_Billing_System{ public partial class DataTransaction : System.Web.UI.Page { String ConnectionString = WebConfigurationManager.ConnectionStrings["myConnectionString"].ToString(); bool found = false; String memberid, name, phonenumber; decimal openbal, due; protected void Page_Load(object sender, EventArgs e) { String machineid = Request.QueryString["MID"]; String cardid = Request.QueryString["CNUM"]; decimal paidamount = Convert.ToDecimal(Request.QueryString["AMT"]); String paiddate = Request.QueryString["TOT"]; String operatorid = Request.QueryString["UPWD"]; if (machineid != null && cardid != null && paidamount != 0 && paiddate != null && operatorid != null) { if (Convert.ToInt32(Request.QueryString["TT"]) == 1) { using (MySqlConnection con = new MySqlConnection(ConnectionString)) { // whether operator id exist or not String browseroperatorid = Request.QueryString["UPWD"].ToString(); String query = "select operator_id from operator"; MySqlCommand command = new MySqlCommand(query, con); con.Open(); using (MySqlDataReader rdr = command.ExecuteReader()) { while(rdr.Read()) { String dboperatorid = rdr["operator_id"].ToString(); if (dboperatorid.Equals(browseroperatorid)) { found = true; break; } } } if (found == true) { // get the details from admin based on card id if operator id exist String selectquery = "select * from admin where card_id= '" + cardid + "'"; MySqlCommand command1 = new MySqlCommand(selectquery, con); using (MySqlDataReader rdr = command1.ExecuteReader()) { if (rdr.Read()) { memberid = rdr["member_id"].ToString(); name = rdr["name"].ToString(); phonenumber = rdr["phone_number"].ToString(); openbal = Convert.ToDecimal(rdr["opening_balance"].ToString()); due = openbal - paidamount; } // card id does not exist else Response.Write("$TS=2#"); } // insert new record into trasaction String insertquery = "insert into transaction(machine_id,operator_id,member_id,card_id,name,paid_amount,due_amount,paid_date,phone_number) values(@machineid,@operatorid,@memberid,@cardid,@name,@paidamount,@dueamount,@paiddate,@phone) "; MySqlCommand command2 = new MySqlCommand(insertquery, con); command2.Parameters.AddWithValue("@machineid", machineid); command2.Parameters.AddWithValue("@operatorid", operatorid); command2.Parameters.AddWithValue("@memberid", memberid); command2.Parameters.AddWithValue("@cardid", cardid); command2.Parameters.AddWithValue("@name", name); command2.Parameters.AddWithValue("@paidamount", paidamount); command2.Parameters.AddWithValue("@dueamount", due); if (paiddate.Length == 14) { string format = "ddMMyyyyHmmss"; DateTime dateTime = DateTime.ParseExact(paiddate, format, System.Globalization.CultureInfo.InvariantCulture); String result = dateTime.ToString("yyyy-MM-dd H:mm:ss"); command2.Parameters.AddWithValue("@paiddate", result); } else//if date does not contain 14 digits,Invalid Transaction. { Response.Write("$TS=2#"); } command2.Parameters.AddWithValue("@phone", phonenumber); command2.ExecuteNonQuery(); Response.Write("$AMT='" + paidamount + "'|BAL='" + due + "'|TS=1# "); //update admin with due amount String updatequery = "update admin set opening_balance='" + due + "' where card_id='" + cardid + "' "; MySqlCommand command3 = new MySqlCommand(updatequery, con); command3.ExecuteNonQuery(); } // invalid operator id else Response.Write("$TS=3#"); } } else if (Convert.ToInt32(Request.QueryString["TT"]) == 2) { using (MySqlConnection con = new MySqlConnection(ConnectionString)) { String browseroperatorid = Request.QueryString["UPWD"].ToString(); String query = "select operator_id from operator"; MySqlCommand command = new MySqlCommand(query, con); con.Open(); using (MySqlDataReader rdr = command.ExecuteReader()) { while (rdr.Read()) { String dboperatorid = rdr["operator_id"].ToString(); if (dboperatorid.Equals(browseroperatorid)) { found = true; break; } } } if (found == true) { String query1 = "select opening_balance from admin where card_id='" + cardid + "' "; MySqlCommand command1 = new MySqlCommand(query1, con); using (MySqlDataReader rdr = command.ExecuteReader()) { if (rdr.Read()) { String bal = rdr["opening_balance"].ToString(); Response.Write("$ BAL='" + bal + "'|TS=1# "); } else// card id does not exist Response.Write("$ TS=2# "); } } else//operator id does not exist Response.Write("$TS=3#"); } } else if (Convert.ToInt32(Request.QueryString["TT"]) == 3) { using (MySqlConnection con = new MySqlConnection(ConnectionString)) { String browseroperatorid = Request.QueryString["UPWD"].ToString(); String query = "select operator_id from operator"; MySqlCommand command = new MySqlCommand(query, con); con.Open(); using (MySqlDataReader rdr = command.ExecuteReader()) { while (rdr.Read()) { String dboperatorid = rdr["operator_id"].ToString(); if (dboperatorid.Equals(browseroperatorid)) { found = true; break; } } } if (found == true) { } } } //invalid transaction } else Response.Write("$TS=2#"); } }}How to check it. 解决方案 TS=2#"); } // insert new record into trasaction String insertquery = "insert into transaction(machine_id,operator_id,member_id,card_id,name,paid_amount,due_amount,paid_date,phone_number) values(@machineid,@operatorid,@memberid,@cardid,@name,@paidamount,@dueamount,@paiddate,@phone) "; MySqlCommand command2 = new MySqlCommand(insertquery, con); command2.Parameters.AddWithValue("@machineid", machineid); command2.Parameters.AddWithValue("@operatorid", operatorid); command2.Parameters.AddWithValue("@memberid", memberid); command2.Parameters.AddWithValue("@cardid", cardid); command2.Parameters.AddWithValue("@name", name); command2.Parameters.AddWithValue("@paidamount", paidamount); command2.Parameters.AddWithValue("@dueamount", due); if (paiddate.Length == 14) { string format = "ddMMyyyyHmmss"; DateTime dateTime = DateTime.ParseExact(paiddate, format, System.Globalization.CultureInfo.InvariantCulture); String result = dateTime.ToString("yyyy-MM-dd H:mm:ss"); command2.Parameters.AddWithValue("@paiddate", result); } else//if date does not contain 14 digits,Invalid Transaction. { Response.Write("TS=2#"); } command2.Parameters.AddWithValue("@phone", phonenumber); command2.ExecuteNonQuery(); Response.Write("AMT='" + paidamount + "'|BAL='" + due + "'|TS=1# "); //update admin with due amount String updatequery = "update admin set opening_balance='" + due + "' where card_id='" + cardid + "' "; MySqlCommand command3 = new MySqlCommand(updatequery, con); command3.ExecuteNonQuery(); } // invalid operator id else Response.Write(" 这篇关于如何调试Web表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的.. 09-07 21:30