Dinesh Santhalingam

Dinesh Santhalingam

  • 1.4k
  • 737
  • 325.8k

How to insert the data to sql table?

Jan 23 2017 12:32 AM
I have some values .I want to insert the values into the Sql table .Here is my code.There were no error  populating.But i can't able to insert the data to sql table.
  1. using (SqlConnection Connection = new SqlConnection((@"Data Source")))  
  2.             {  
  3.              using (SqlCommand myCommand = new SqlCommand("INSERT INTO table1(Nameofbike,Totalbike,
  4.                                                    Inuse)", Connection))  
  5.            {  
  6.            Connection.Open();  
  7.            myCommand.Parameters.Add(new SqlParameter("Nameofbike", "Hero"));  
  8.            myCommand.Parameters.Add(new SqlParameter("Totalbike", "15"))  
  9.            myCommand.Parameters.Add(new SqlParameter("Inuse", "10"));  
  10.                       
  11.             }  
  12.                Connection.Close();  
  13.             }  
 

Answers (4)