User-527908287 posted
i tried to effect an update on user wallet table and got an error https://imgur.com/VALYBXA
I have a UserWallet table which this update will take place after fetching an existing record and adding the new amount to it and update. these update will be done after receiving response from payment gateway on successful payment
client.AddDefaultHeader("Authorization", "Bearer sk_test_065xxxxxxxxxxxxxxxxxxxxxxxx");
IRestResponse response = client.Execute(request);
if (response.IsSuccessful)
{
var jsonResponse = response.Content;
var verificationResponse = JsonConvert.DeserializeObject<PaymentResponse>(jsonResponse);
if (verificationResponse.status && verificationResponse.data.status == "success")
{
var amountPaid = (verificationResponse.data.amount / 100);
var customerEmail = verificationResponse.data.customer.email;
UpdateWallet(customerEmail, amountPaid);
//write your update query here.......
}
else
{
}
}
else
{
}
}
private void UpdateWallet(string email, decimal amount)
{
SqlConnection conn = new SqlConnection("Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\\Dataregister.mdf;Integrated Security=True");
string query = "SELECT Amount FROM UserWallet where Email = @email", con;
var cmd = new SqlCommand(query, conn);
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
reader.Read();
var Amount = reader["Amount"].ToString() + @amount;
string strSql = "update UserWallet set Amount ='" + amount + "' where Email = @email ";
SqlCommand cmd2 = new SqlCommand(strSql, conn);
cmd2.Parameters.AddWithValue("@amount", amount);
cmd2.ExecuteNonQuery();
conn.Close();
}
from the top of the code is where the payment response comes in JsonResponse and in the yellow highlighted area is my c# code to effect updates of thie megnitude.