Неправильный синтаксис рядом с ':'.
Привет,
Оцените некоторые советы "гуру", попробуйте решить эту проблему.
public class Service1 : System.Web.Services.WebService { [WebMethod] public string VoidTransaction (string merchantcode, string cctransid, string amount, string currency, string signature) { string dbKey = ""; string dbMerchantId = ""; if (merchantcode == "") { return "Merchant Code is empty"; } else if (cctransid == "") { return "Transaction ID is empty"; } else if (amount == "") { return "Amount is empty"; } else if (currency == "") { return "Currency is empty"; } else if (signature == "") { return "Signature is empty"; } else { string ConnectionString = ""; SqlConnection myConnection; myConnection = new SqlConnection(ConnectionString); myConnection.ConnectionString = WebConfigurationManager.AppSettings["WebSvcDb"]; myConnection.Open(); string sqlGetKey = ("SELECT MerchantKey, MerchantId from eMerchant where MerchantCode = '"+merchantcode+ "'"); SqlCommand cmdGet = new SqlCommand(sqlGetKey, myConnection); SqlDataReader drGet = cmdGet.ExecuteReader(); if (drGet.Read()) { dbKey = drGet["MerchantKey"].ToString(); dbMerchantId = drGet["MerchantId"].ToString(); } drGet.Close(); myConnection.Close(); } if (signature != "") { string tempAmount = "0.00"; tempAmount = amount.Replace(",", "").Replace(".", ""); string tempString = dbKey + merchantcode + cctransid + tempAmount + currency; string tempSign = Security(tempString); if (tempSign != signature) { return "Signature not match"; } } return CheckVoidFunction(merchantcode, cctransid, amount, currency, dbMerchantId); } private string CheckVoidFunction(string merchantcode, string transactionid, string amount, string currency, string MerId) { string ConnectionString = ""; string dbPayId = ""; string dbMiddetails = ""; string dbIdentityCode = ""; string dbAmount = ""; string dbComments = ""; string dbPaybank = ""; string dbCurrency = ""; string dbMerchantName = ""; string dbMerchantId = ""; SqlConnection myConnection; myConnection = new SqlConnection(ConnectionString); myConnection.ConnectionString = WebConfigurationManager.AppSettings["WebSvcDb"]; myConnection.Open(); string sqlGetTransactionDetail = ("SELECT p.PayId, p.MidDetails, p.IdentityCode, p.Amount, p.Comments, p.Paybank, p.Currency, p.MerchantId, m.MerchantName from ePayment p, eMerchant m where m.MerchantId = p.MerchantId and p.CCTransId = '" + transactionid + "'"); SqlCommand cmd = new SqlCommand(sqlGetTransactionDetail, myConnection); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { dbPayId = dr["MidDetails"].ToString(); dbMiddetails = dr["MidDetails"].ToString(); dbIdentityCode = dr["IdentityCode"].ToString(); dbAmount = dr["Amount"].ToString(); dbComments = dr["Comments"].ToString(); dbPaybank = dr["Paybank"].ToString(); dbCurrency = dr["Currency"].ToString(); dbMerchantId = dr["MerchantId"].ToString(); dbMerchantName = dr["MerchantName"].ToString(); dr.Close(); myConnection.Close(); if (decimal.Round(decimal.Parse(dbAmount.ToString()), 2).ToString() != amount) { return "Invalid Amount"; } else if (dbCurrency != currency) { return "Invalid Currency"; } else if (dbMerchantId != MerId) { return "Invalid Merchant Code"; } else { if (dbPaybank == "44") { return PBBVoidFunction(merchantcode, transactionid, amount, currency, dbPayId, dbMiddetails, dbIdentityCode, dbAmount, dbComments, dbPaybank, dbMerchantName); } else { return "This transaction is not eligible for voiding"; } } } else { dr.Close(); myConnection.Close(); return "Transaction not found"; } } private string PBBVoidFunction(string merchantcode, string transactionid, string amount, string currency, string dbPayId, string dbMiddetails, string dbIdentityCode, string dbAmount, string dbComments, string dbPaybank, string dbMerchantName) { string ConnectionString = ""; string BinNum = ""; string VisaMID = ""; string MasterMID = ""; string TID = ""; string LiveStatus = ""; string PadTransId = ""; string PadAmount = ""; string QSTRING = ""; string tempURL = ""; string merID = ""; string tempResult = ""; string sqlUpdateTransaction = ""; if (dbIdentityCode != "") { BinNum = dbIdentityCode.Substring(0, 6); } if (dbMiddetails != "") { string[] stringSeparators = new string[] { ":||:" }; string[] result = dbMiddetails.Split(stringSeparators, StringSplitOptions.None); if (result.Length > 0) { VisaMID = result[0]; MasterMID = result[1]; TID = result[2]; LiveStatus = result[3]; } } if (BinNum.Substring(0, 1) == "4") { merID = VisaMID; } else if (BinNum.Substring(0, 1) == "5") { merID = MasterMID; } PadTransId = transactionid.PadLeft(20, '0'); PadAmount = decimal.Round(decimal.Parse(dbAmount.ToString()), 2).ToString().Replace(".", "").Replace(",", "").PadLeft(12, '0'); QSTRING = "transactionType=0400&merID=" + merID + "&invoiceNo=" + PadTransId + "&amount=" + PadAmount; if (LiveStatus == "0") { tempURL = "https://uattds2.pbebank.com/PGW/Pay/Process"; } else { tempURL = "https://ecom.pbebank.com/PGW/Pay/Process"; } ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = (SecurityProtocolType)(0xc0 | 0x300 | 0xc00); // Create a request using a URL that can receive a post. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(tempURL); // Set the Method property of the request to POST. request.Method = "POST"; // Create POST data and convert it to a byte array. byte[] byteArray = Encoding.UTF8.GetBytes(QSTRING); // Set the ContentType property of the WebRequest. request.ContentType = "application/x-www-form-urlencoded"; // Set the ContentLength property of the WebRequest. request.ContentLength = byteArray.Length; // Get the request stream. Stream dataStream = request.GetRequestStream(); // Write the data to the request stream. dataStream.Write(byteArray, 0, byteArray.Length); // Close the Stream object. dataStream.Close(); // Get the response. WebResponse response = request.GetResponse(); // Get the stream containing content returned by the server. dataStream = response.GetResponseStream(); // Open the stream using a StreamReader for easy access. StreamReader reader = new StreamReader(dataStream); // Read the content. string responseFromServer = reader.ReadToEnd(); // Clean up the streams. reader.Close(); dataStream.Close(); response.Close(); string PBBresponse = ""; string PBBauthCode = ""; string PNNinvoiceNo = ""; string PBBPAN = ""; string PBBExpDate = ""; string PBBAmount = ""; PBBresponse = responseFromServer.Substring(0, 2); PBBauthCode = responseFromServer.Substring(2, 6); PNNinvoiceNo = responseFromServer.Substring(8, 20); PBBPAN = responseFromServer.Substring(28, 4); PBBExpDate = responseFromServer.Substring(32, 4); PBBAmount = responseFromServer.Substring(36, 12); dbComments = dbComments + "iPay88:VoidTransaction|" + "iPay88Date:" + DateTime.UtcNow.AddHours(8) + "|" + "response:" + PBBresponse + "|" + "authCode:" + PBBauthCode + "|" + "invoiceNo:" + PNNinvoiceNo + "|" + "PAN:" + PBBPAN + "|" + "ExpDate:" + PBBExpDate + "|" + "Amount:" + PBBAmount + "||"; if (PBBresponse == "00") { sqlUpdateTransaction = "Update ePayment set PayStatus = 17, Comments = '" + dbComments + "' where PayId = " + dbPayId + ""; } else { sqlUpdateTransaction = "Update ePayment set Comments = '" + dbComments + "' where PayId = " + dbPayId + ""; } tempResult = PBBresponse; if (sqlUpdateTransaction != "") { SqlConnection myConnection; myConnection = new SqlConnection(ConnectionString); myConnection.ConnectionString = WebConfigurationManager.AppSettings["WebSvcDb"]; myConnection.Open(); SqlCommand cmdUpdate = new SqlCommand(sqlUpdateTransaction, myConnection); cmdUpdate.ExecuteNonQuery(); myConnection.Close(); } return tempResult; }
Спасибо.
Любые указатели благодарны.
Спасибо
Риксон
Что я уже пробовал:
ServicePointManager.SecurityProtocol = (SecurityProtocolType)(0xc0 | 0x300 | 0xc00);
Richard MacCutchan
Так что где-то во всем этом коде есть двоеточие, которого там быть не должно. Но вы не сочли это достаточно важным, чтобы сказать нам, где именно он находится. Я могу только предположить, что, поскольку вы создаете все свои SQL-операторы неправильно, это где-то там.
Patrice T
Дайте точное сообщение об ошибке, оно также сообщает Номер строки.