3
Answers

Does C# support ADO.Net to access Data ?

Edward Aymami

Edward Aymami

1y
508
1

Trying to create a Data dll usnin C# in VS2019. Does C# support ADO.Net ?

Answers (3)
1
Vishal Joshi

Vishal Joshi

244 7.8k 135.4k 1y

Hello Edward,

C# is the language. you can create console, desktop, web application etc with the help of c# language.

to use ADO.NET you need to use below system namespaces.

using System.Data;
using System.Configuration;
using System.Data.SqlClient;

private void GetData()
{
    string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
    string query = "SELECT * FROM Customers";
    using (SqlConnection con = new SqlConnection(constr))
    {
        using (SqlDataAdapter sda = new SqlDataAdapter(query, con))
        {
            using (DataTable dt = new DataTable())
            {
                sda.Fill(dt);
                // use DataAdapter to bind data to grid or you can utilize as per requirement.
            }
        }
    }
}

 

Thanks

Accepted
0
Vishal Joshi

Vishal Joshi

244 7.8k 135.4k 1y

Hello Edward,

Yes. it will work for VS2019. 

0
Edward Aymami

Edward Aymami

NA 21 3.5k 1y

Does this work for VS2019? also thank you for the quick response.