Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

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

SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source = (LocalDB)MSSQLLocalDB; AttachDbFilename = C:UsersHarryDocumentsVisual Studio 2015WebSitesWebSite2App_DataDatabase.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();
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# control datagridview null value 
Csharp :: convert web app to linux 
Csharp :: button pervious for picturebox c# 
Csharp :: unity slider decimal 0.01 
Csharp :: asp.net core reverse engineer database 
Csharp :: Set database timeout in Entity Framework 
Csharp :: how to check if every element in array is true c# 
Csharp :: telerik mvc grid required field 
Csharp :: invalid length for a base-64 char array or string. frombase64string c# 
Csharp :: how to run a console app in another app c# 
Csharp :: c# unary operator 
Csharp :: radio buttons into database stackoverflow 
Csharp :: epmty char c# 
Csharp :: bitwise even or odd 
Csharp :: C# devexpress get foucused dataRow of child gridView 
Csharp :: Post and Pre Increment operators in C# 
Csharp :: unity wheelcollider antiroll 
Csharp :: filter collection viewbag 
Csharp :: Valid date check with DateTime.TryParse method 
Csharp :: unity having virtual start 
Csharp :: null objects 
Csharp :: net use error 67 
Csharp :: c# office interop copy slide to another pppt 
Csharp :: Difference between Math.Floor() and Math.Truncate() 
Csharp :: extension method c# 
Csharp :: c# enum to string 
Csharp :: c# loop backwards 
Csharp :: transform.rotate unity 2d 
Csharp :: web scraping dynamic content c# 
Csharp :: c# web page show 2nd page of tiff on an image control 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =