Rahul  Pandey
How to creating a SqlCommand Object?
By Rahul Pandey in ADO.NET on Jul 01 2013
  • Bharathi Raja
    Feb, 2018 1

    using(SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["connSpionshopString"].ConnectionString)) {connection.Open();string sql = "INSERT INTO klant(klant_id,naam,voornaam) VALUES(@param1,@param2,@param3)";SqlCommand cmd = new SqlCommand(sql,connection);cmd.Parameters.Add("@param1", SqlDbType.Int).value = klantId cmd.Parameters.Add("@param2", SqlDbType.Varchar, 50).value = klantNaam;cmd.Parameters.Add("@param3", SqlDbType.Varchar, 50).value = klantVoornaam;cmd.CommandType = CommandType.Text;cmd.ExecuteNonQuery(); }

    • 1
  • Srinivas Pabballa
    Aug, 2015 28

    syntax to create SqlCommand object SqlCommand = new SqlCommand("Command to execute i.e. (select,insert,update,delete))", connection objectname);ex: if u want to retrieve data from sql server we use select command i.e SqlComand cmd = new SqlCommnd("Select * from Table_Employee",conn);conn--> SqlConnection Object cmd--> SqlCommand Object

    • 0
  • Rahul Prajapat
    May, 2015 26

    Sqlcommand com=new Sqlcommand(query,connection object);

    • 0
  • Pramod Lawate
    Aug, 2013 27

    Using(Sqlcommand cmd = new Sqlcommand(Select * from TableName,Sqlconnection)) {//Your code here }

    • 0
  • Sreekanth Reddy
    Jul, 2013 9

    sqlcommand cmd=new sqlcommand("select * from emp",con);con- connection object.

    • 0
  • Priti Kumari
    Jul, 2013 2

    SqlConnection con = new SqlConnection("Data Source=ABC;Initial Catalog=studentdetail;uid=sa; pwd=Password1");SqlCommand cmd = new SqlCommand("Select * from Tablename",connection); con.open();

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS