Click here to Skip to main content
15,902,837 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
C#
public void ConnectDataBaseToInsert(string Query)
   {
       con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\omar\Documents\Visual Studio 2005\WebSites\Project2\App_Data\Database.mdf;Integrated Security=True;User Instance=True");

       cmd.CommandText = Query; //what does this line do?
       cmd.Connection = con; //what does this line do?
       da = new SqlDataAdapter(cmd); //what does this line do?
       con.Open();
       cmd.ExecuteNonQuery();
       con.Close();
   }

1)what is cmd.commandtext?
2)What is Sqldataadapter(cmd)
Posted
Updated 17-Jun-11 2:56am
v2
Comments
Richard MacCutchan 17-Jun-11 9:50am    
How many more of these inane questions are you going to post? Get a book, learn to use Google, and start doing some studying for yourself.
Sergey Alexandrovich Kryukov 17-Jun-11 16:32pm    
I report it all as spam/abuse. Regular questions on the code OP did not right. Useless for OP, destruction for CodeProject members.
--SA

cmd.CommandText = Query;what this line do?

It tells the SqlCommand object that the Command text is a sql query (as opposed to a stored procedure name)

cmd.Connection = con;what this line do?

This sets the SqlCommand object to use the specified SqlConnection

da = new SqlDataAdapter(cmd);what this line do?

This instantiates a SqlDataAdapter with the SqlCommand object, and allows you to access the returned data.

----

Seriously, if you're so freakin' lazy that you can't do some minor googling to find these answers, your career as a programmer will be very short-lived.
 
Share this answer
 
v2
Comments
Albert Holguin 17-Jun-11 8:57am    
agree on all points... specially that last one... lol
Sergey Alexandrovich Kryukov 17-Jun-11 16:33pm    
John, look at the other OP's questions and my comment to the question. I report it all as spam/abuse.
--SA
If you are using Visual Studio IDE

why don't you right click on the code, and use Go to Definition, there you can view all the details of each and every property or method.

hope this helps :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900