我有一個聲明插入到我的數據庫,但插入後我想更新我的數據在表webservice
。我該怎麼做?插入數據庫webservice後更新數據
這是我插入數據代碼:
[WebMethod]
public static void InsertStudentTransaction(string Name, string CLass, string NRIC, int StallNo, float AmountSpent, DateTime GetDate)
{
using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString2"].ConnectionString))
{
SqlCommand command = new SqlCommand("INSERT Into StudentTransactions (Name, CLass,NRIC,StallNo,AmountSpent, TimeDate) VALUES (@Name, @CLass, @NRIC, @StallNo, @AmountSpent, @GetDate)");
command.Parameters.AddWithValue("@Name", "Name");
command.Parameters.AddWithValue("@CLass", "CLass");
command.Parameters.AddWithValue("@NRIC", "NRIC");
command.Parameters.AddWithValue("@StallNo","StallNo");
command.Parameters.AddWithValue("@AmountSpent", "AmountSpent");
command.Parameters.AddWithValue("@TimeDate", "GetDate");
command.Connection.Open();
command.ExecuteNonQuery();
}
任何例子讓我看看直通? –