5
Reply

How to creating a SqlCommand Object?

Rahul  Pandey

Rahul Pandey

11y
1.5k
0
Reply

    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

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

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

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

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