这是OrderDetails页面,在shoppingcart成功购买后将被带到此页面。 1)当我让代码运行时,javascript弹出窗口没有像我的其他页面那样弹出。 2)rdr = cmd.executereader()是导致错误页面的错误 3)SELECT * OrdersView是另一个错误。 [我编辑为SELECT * FROM ordersView] *新错误* 4)所有这些代码都不再给我错误。但是没有弹出窗口,也没有电子邮件发送到该帐户。
我对这个错误的看法:一些分析。我尝试了字符串StrFirstName部分alacartely和会话[“sfirstname”] alacartely也导致相同的错误。所以我发布了两个提取物给你看。
我在c#中并不是那么好,但我相信它是由于我使用*而不是FROM检索数据库而且还因为我没有正确检索我需要的部分(逻辑错误,我推测)任何人都可以指导我这个问题?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Net.Mail;
public partial class OrderDetails : System.Web.UI.Page
{
static readonly string scriptSuccessPaymentSuccessful =
"<script language=\"javascript\">\n" +
"alert (\"Your payment is successful!- Thank you!\");\n" +
"</script>";
protected void Page_Load(object sender, EventArgs e)
{
OleDbConnection mDB = new OleDbConnection();
mDB.ConnectionString = "Provider = Microsoft.ACE.OLEDB.12.0;Data Source=" + Server.MapPath("~/App_Data/webBase.accdb");
mDB.Open();
Type csType = this.GetType();
OleDbCommand cmd;
OleDbDataReader rdr;
string SQLRetrieve = "SELECT * FROM ordersView";
cmd = new OleDbCommand(SQLRetrieve, mDB);
rdr = cmd.ExecuteReader();
while (rdr.Read() == true)
{
{
string strFirstName = rdr["CFirstName"].ToString();
string strLastName = rdr["CLastName"].ToString();
string strEmail = rdr["CEmail"].ToString();
string strOrderNo = rdr["oOrderNo"].ToString();
string strStatus = rdr["oStatus"].ToString();
string strPaymentMode = rdr["oPaymentMode"].ToString();
string strPrice = rdr["SumOfuUnitPrice"].ToString();
if ((string)Session["sFlag"] != "T")
{
ClientScript.RegisterStartupScript(csType, "Success", scriptSuccessPaymentSuccessful);
//
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress("kayzelmoo@gmail.com");
mailMessage.To.Add(strEmail);
mailMessage.Subject = "DreamJagers - Successful transaction";
mailMessage.Body = "<b>Dear : </b>" + strFirstName + " " + strLastName + "," + "<br/>"
+ "<b>Order No : </b>" + strOrderNo + "<br/>"
+ "<b>Payment Mode: </b>" + "You have paid with " + strPaymentMode + "<br/>"
+ "<b>Amount Paid: </b>" + "$SGD" + strPrice + "<br/>"
+ "<b>Message : </b>" + "DreamJagers thank you for making the purchase with us, you can present this E-mail to any of us as a proof of receipt purchase";
mailMessage.IsBodyHtml = true;
SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
smtpClient.EnableSsl = true;
smtpClient.Credentials = new System.Net.NetworkCredential("kayzelmoo@gmail.com", "xxxxxxxxx");
smtpClient.Send(mailMessage);
}
else
{
}
}
}
}
}
答案 0 :(得分:0)
好好开始
SELECT * ordersView
应该是
SELECT * FROM ordersView
您的代码不会向rdr返回任何内容,因为语法错误。
这很可能是问题但是如果不是答案,那么你不会给我们提供我们需要的实际错误。