Friday, May 8, 2009

Connect You C# Form Application with MS SQL server Database

Inserting data into SQL is pretty straightforward and simple. Using the SQL command string, you insert specific values for specific columns. The actual insertion is initiated using the cmd.Execute-NonQuery() command. This executes a command on the data when you don’t want anything in return.



using System.Data.SqlClient
– This namespace defines a data provider for the SQL Server 7.0 or higher databse.It contains classes such as sqlconnection and sqlcommand.

ConnectionString - This property allows you to read or provide the connection string that should be used by the SqlConnection object.
CommandText – This read/write property allows you to set or retrieve either T-SQL statement or the name of the stored procedure.
Connection – This read /write property gets or sets the sqlConnection object that should be used by this command Object..
ExecuteNonQuery – This method executes the command specified and return the number of row affected.

No comments: