0% found this document useful (0 votes)
5 views2 pages

c# and sql server

.NET Framework is a Microsoft software development framework that provides a controlled environment for Windows applications, featuring the Common Language Runtime (CLR) and Base Class Library (BCL). Key classes for database operations include SqlConnection for establishing connections, SqlDataAdapter for data retrieval and saving, SqlCommand for executing SQL statements, and DataSet and DataTable for managing in-memory data. The ExecuteNonQuery method of SqlCommand is used for executing SQL commands that do not return results, such as INSERT, UPDATE, and DELETE.

Uploaded by

ahmed mohamed
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
5 views2 pages

c# and sql server

.NET Framework is a Microsoft software development framework that provides a controlled environment for Windows applications, featuring the Common Language Runtime (CLR) and Base Class Library (BCL). Key classes for database operations include SqlConnection for establishing connections, SqlDataAdapter for data retrieval and saving, SqlCommand for executing SQL statements, and DataSet and DataTable for managing in-memory data. The ExecuteNonQuery method of SqlCommand is used for executing SQL commands that do not return results, such as INSERT, UPDATE, and DELETE.

Uploaded by

ahmed mohamed
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 2

C# and SQL Server

.NET Framework
The .NET Framework is a software development framework developed by Microsoft. It
provides a controlled environment for developing and running applications on Windows.
Key features of the .NET Framework include:
- Common Language Runtime (CLR): Executes .NET programs and provides services
like memory management, type safety, exception handling, and garbage collection.
- Base Class Library (BCL): Provides a comprehensive set of classes and interfaces that
provide a wide range of functionalities such as file I/O, data access, cryptography, web
application development, numeric algorithms, and network communications.

SqlConnection
`SqlConnection` is a class in the .NET Framework's `System.Data.SqlClient` namespace.
It represents a connection to a SQL Server database. It is used to open a database
connection and execute commands against the database.
using System.Data.SqlClient;
SqlConnection conn = new SqlConnection("your_connection_string");
conn.Open();
// Perform database operations
conn.Close();

SqlDataAdapter
`SqlDataAdapter` is a class that serves as a bridge between a `DataSet` and a SQL Server
database for retrieving and saving data. It uses `SqlCommand` objects to execute SQL
commands. It is commonly used to fill a `DataSet` with data from a database and to
update the database with changes made in the `DataSet`.
//conn your sql connection
SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM your_table", conn);

DataSet ds = new DataSet();

adapter.Fill(ds);
SqlCommand
`SqlCommand` is a class that represents a SQL statement or stored procedure to execute
against a SQL Server database. It is used to execute queries, commands, or stored
procedures.
SqlCommand command = new SqlCommand("SELECT * FROM your_table", conn);
SqlDataReader reader = command.ExecuteReader();

ExecuteNonQuery
`ExecuteNonQuery` is a method of the `SqlCommand` class that executes a SQL
command that does not return any results. It is typically used for executing SQL
statements like `INSERT`, `UPDATE`, `DELETE`, and DDL (Data Definition
Language) commands.

SqlCommand command = new SqlCommand("INSERT INTO your_table


(column1, column2) VALUES (value1, value2)", conn);
int rowsAffected = command.ExecuteNonQuery();

DataSet
`DataSet` is a class that represents an in-memory cache of data. It is a collection of
`DataTable` objects and can be used to manage and manipulate data from multiple
sources.
DataSet ds = new DataSet();
adapter.Fill(ds);

DataTable
`DataTable` is a class that represents one table of in-memory data. It is part of the
`DataSet` and can be used independently. A `DataTable` consists of rows and columns.

// Get the first DataTable from the DataSet


DataTable dt = ds.Tables[0];

You might also like