Answers for "How to solve error in ExecuteNonQuery() in asp.net"

C#
0

How to solve error in ExecuteNonQuery() in asp.net

SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename = C:\Users\Harry\Documents\Visual Studio 2015\WebSites\WebSite2\App_Data\Database.mdf; Integrated Security = True";
con.Open();

// insert command 
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText="INSERT INTO firsttb VALUES ( @n , @p ) ";
cmd.CommandType = System.Data.CommandType.Text;
cmd.Parameters.AddWithValue("@n",TextBox1.Text);
cmd.Parameters.AddWithValue("@p", TextBox2.Text);

cmd.ExecuteNonQuery();

con.Close();
Posted by: Guest on June-13-2020

Code answers related to "How to solve error in ExecuteNonQuery() in asp.net"

C# Answers by Framework

Browse Popular Code Answers by Language