Sir,
I am new to asp.net i have installed visual studio community 2022 i want to know how to add 2 values and display the output, i need step procedure. please guide me
Sir,
I am new to asp.net i have installed visual studio community 2022 i want to know how to add 2 values and display the output, i need step procedure. please guide me
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satya KarkiRank #78 · 24.6K reputationPosted Mar 15, 2022, 1:45 AM EDT
Mohamed Rafi160 reputationPosted Mar 16, 2022, 1:04 AM EDT
Arnab MukherjeeRank #879 · 2.5K reputationPosted Mar 16, 2022, 1:32 AM EDT
Hi, If you are using ASP.NET Web Form then please add 3 textbox and a button. Now paste the below code in .aspx.cs button click event and put your DB connection string. This is how, you can add 3 values in a table.
protected void btnInsert_Click(object sender, EventArgs e)
{
var cnnString = "Your DB ConnectionString";
var cmd = "insert into TableName values(@Name,@Address,@Phone)";
using (SqlConnection cnn = new SqlConnection(cnnString))
{
using (SqlCommand cmd = new SqlCommand(cmd, cnn))
{
cmd.Parameters.AddWithValue("@Name",txtName.Text);
cmd.Parameters.AddWithValue("@Address",txtAddress.Text);
cmd.Parameters.AddWithValue("@Phone",txtPhone.Text);
cnn.Open();
cmd.ExecuteNonQuery();
}
}
}
Mohamed Rafi160 reputationPosted Mar 16, 2022, 3:29 AM EDT
Mohamed Rafi160 reputationPosted Mar 16, 2022, 3:44 AM EDT
Mohamed Rafi160 reputationPosted Mar 16, 2022, 5:09 AM EDT
Muhammad Imran AnsariRank #326 · 7.6K reputationPosted Mar 16, 2022, 5:16 AM EDT