C# Corner
Tech
News
Videos
Forums
Trainings
Books
Events
More
Interviews
Jobs
Live
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
.NET
ADO.NET
Android
ASP.NET
C#
Databases & DBA
Design Patterns & Practices
Java
Learn iOS Programming
OOP/OOD
SharePoint
Software Testing
Web Development
WPF
View All
6
Reply
How to creating a SqlCommand Object?
Rahul Pandey
12y
2.7k
0
Reply
Delete Row
Delete Column
Insert Link
×
Insert
Cancel
Embed YouTube Video
×
Width (%)
Height (%)
Insert
Cancel
Table Options
×
Rows
Columns
First row as header
Create Table
Insert Image
×
Selected file:
Alignment
Left
Center
Right
Select an image from your device to upload
Upload to Server
Cancel
Submit
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(); }
Bharathi Raja
7y
1
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
Srinivas Pabballa
10y
0
Sqlcommand com=new Sqlcommand(query,connection object);
Rahul Prajapat
10y
0
Using(Sqlcommand cmd = new Sqlcommand(Select * from TableName,Sqlconnection)) {//Your code here }
Pramod Lawate
12y
0
sqlcommand cmd=new sqlcommand("select * from emp",con);con- connection object.
Sreekanth Reddy
12y
0
SqlConnection con = new SqlConnection("Data Source=ABC;Initial Catalog=studentdetail;uid=sa; pwd=Password1");SqlCommand cmd = new SqlCommand("Select * from Tablename",connection); con.open();
Priti Kumari
12y
0
What are different types of Commands available with DataAdapter ?
What is the provider and namespaces being used to access oracle database?
Message