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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Muhammad Imran AnsariPosted Mar 16, 2022, 9:16 AM
Mohamed RafiPosted Mar 16, 2022, 9:09 AM
Mohamed RafiPosted Mar 16, 2022, 7:44 AM
Mohamed RafiPosted Mar 16, 2022, 7:29 AM
Arnab MukherjeePosted Mar 16, 2022, 5:32 AM
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 RafiPosted Mar 16, 2022, 5:04 AM
Satya KarkiPosted Mar 15, 2022, 5:45 AM