Aspnetcore: How to use ADO.NET in asp.net core 1.0?

Created on 6 Jul 2016  ·  3Comments  ·  Source: dotnet/aspnetcore

Please guide me to use ado.net in asp.net core 1.0

Most helpful comment

You should include SqlClient to your project.json.

 "frameworks": {
    "netstandard1.3": {
      "dependencies": {
        "System.Data.SqlClient": "4.1.0-*"
      }
    }
  }

Then you will be able to use old fashion sql connection:

   using (SqlConnection connection = new SqlConnection(connectionString))
   {
           connection.Open();
           using (SqlCommand command = new SqlCommand("SELECT * FROM dbo.Test", con))
           {
                  var reader = command.ExecuteReader();
                  // map your reader
           }
    }

All 3 comments

You should include SqlClient to your project.json.

 "frameworks": {
    "netstandard1.3": {
      "dependencies": {
        "System.Data.SqlClient": "4.1.0-*"
      }
    }
  }

Then you will be able to use old fashion sql connection:

   using (SqlConnection connection = new SqlConnection(connectionString))
   {
           connection.Open();
           using (SqlCommand command = new SqlCommand("SELECT * FROM dbo.Test", con))
           {
                  var reader = command.ExecuteReader();
                  // map your reader
           }
    }

Another scenario:

Imports Oracle.DataAccess
Imports Oracle.DataAccess.Client

Closing because there doesn't appear to be any further action required on this issue.

Was this page helpful?
0 / 5 - 0 ratings