Questions tagged [ado.net]

ADO.NET is a set of computer software components that programmers can use to access data and data services based on disconnected DataSets and XML. It is a part of the base class library that is included with the Microsoft .NET Framework. It is commonly used by programmers to access and modify data stored in relational database systems, though it can also access data in non-relational sources.

Filter by
Sorted by
Tagged with
1 vote
1 answer
1k views

Try-catch-finally with 'using' in ADO.NET

I want to check if I'm correctly disposing of resources using Ado.NET. I'm not sure when the 'using' statement makes .Dispose() irrelevant. Please bear in mind I'm aware I shouldn't hardcode my SQL ...
1 vote
2 answers
135 views

IPAddress Range access

I want to make this code better and easier to read. It works now but I think it can be better. When there is an Inbound request I check to see if that accessKey is setup for IP address Range that will ...
3 votes
2 answers
4k views

Cancel Long Running Query using Cancellation Token AND SqlCommand.Cancel()

I need to be able to cancel a long running query programmatically through our application. The code below will kick off a long running query and give control back to the main thread. At any ...
3 votes
1 answer
151 views

Improvements to data access layer

...
2 votes
1 answer
1k views

Open-source C# client for ClickHouse database

I've created an Open-source ADO.NET driver for ClickHouse database: ClickHouse.Client Would appreciate if someone has any hints to improve code quality/performance (or suggest new ideas) The core ...
1 vote
1 answer
561 views

A Class to Supply an Open Database Connection during the life of a Web Request

For some database requests, I like to use raw ADO.NET. In the context of a web request, I have created a class which provides an open IDbConnection object. I use ...
4 votes
3 answers
2k views

Method that fetches rows from database and maps it to a Model class with SqlDataReader

So, I have a project that has a lot of methods that look alike. In the below method as you can see it just fetches a bunch of rows from database and maps it to a model class. In this case ...
9 votes
4 answers
5k views

Extremely basic login system in console

This is my first C# project. I still am a noob to programming, and while I'm happy I carried out this project, I know that my code needs A LOT of improving and that's why I posted it here. This code ...
3 votes
3 answers
4k views

ADO.NET database access layer

I am attempting to create a database access layer. I am looking for some improvements to this class/recommendations on best practice. It would be helpful if someone could point me to documentation on ...
2 votes
1 answer
2k views

DataReader to To IEnumerable<object[]> To 2 Dimensional Array

Let me preface this with a few things before I get into my question: I am making the leap from VBA/VB6 to .NET, (boy is it a big one), so I am noob to .NET best ...
4 votes
1 answer
828 views

Data Access Layer to return Data Transformation object

I am trying to create a Data Access Layer using ADO.Net. I have created a generic method for ExecuteNonQuery. The stored procedure I am calling will return two parameters. The output parameters from ...
13 votes
1 answer
11k views

Unit of Work (UoW) pattern with ADO.NET

I'm trying to implement the UoW pattern using ADO.NET and this is what I've achieved so far: The IUnitOfWork Interface: ...
1 vote
1 answer
115 views

Initialize various commands for the SqlDataAdapter

This is my code for my SqlDataAdapter which is similar to the code example given in the docs: ...
2 votes
2 answers
856 views

ADO.NET DAO Layer Design With Base DAO

I have a database with a number of stored procedures. These stored procedures provide the basic CRUD operations against the data. I'm trying to create a DAO layer with separate DAOs for each domain ...
4 votes
2 answers
107 views

Simple locale loader

I have a class that loads locales from a database. I'm not sure if locale is the right word. It's basically loading texts for a game, generic sayings like alerts and error messages. I'm also not sure ...
-1 votes
1 answer
3k views

Ado.Net and Async insert of many rows to db

I have implemented repository in Ado.Net which insert data to many tables. I insert all in one transaction and use async/await to improve performances. If you have any suggestions have to improve my ...
3 votes
1 answer
2k views

Implementing RecordSet-like class in C#

From the outset, let me state that I'm working with some older technology. I'd rather use Entity Framework, but I have to use what the client is using if I want to get paid. I am converting some old ...
2 votes
1 answer
184 views

Creating a Dynamic Select Statement from 2 databases on the same server

Can someone improve on my method for creating union select views from 2 databases located within the same server in C#, here is the code for the method: ...
2 votes
2 answers
4k views

Merge two DataTables by adding corresponding entries

I've been looking over internet for a method of combining 2 datatables with exactly the same cells with numbers to add them together, Merge method never help because it just appended the second table. ...
3 votes
2 answers
5k views

Class for managing database connections

Looking for feedback for a class I'm writing to manage my db connections/queries on my site (.net core c# web api, MS Sql DB). The reason behind the class was the ever growing list of db calls and ...
3 votes
2 answers
146 views

Return office details from multiple tables

The function itself is just returning as void. But, the point of the posted code is not about what the function is returning. It is the code related to using T-SQL ...
1 vote
3 answers
145 views

Generate 10000 matrix barcodes

When generating a matrix barcode, it takes 1 minute per 10000 files .That's how to generating a matrix barcode for big quantities in less time. Here is the library used to encoder data. My code for ...
3 votes
1 answer
8k views

Retrieving data in an SQL database and displaying the retrieved data in ASP.NET

I wanted to know other ways where you can access data from the database into the asp.net website that I've created for displaying details and images. As well as looking for better ways to use those ...
3 votes
2 answers
101 views

Display information returned from feedservice and SQL querys on WPF window

The class file below handles the display of information to a WPF window. In its current state it works except for the fast it takes 2 minutes for the window to open because of the SQL query's and ...
2 votes
0 answers
8k views

Mapping Excel columns to table columns, then processing data

I have written some code for mapping excel columns to table columns and processing data after mapping columns. Please review this code, check for SOLID, OOP principles and suggest any improvements and ...
4 votes
1 answer
1k views

ADO.NET Wrapper

I end up writing a lot of the same code when I query a database I thought I would try to encapsulate that all in a class that could be used by any provider that implemented IDbConnection. i'm not ...
6 votes
3 answers
11k views

C# function to execute queries in a SQL Server database [closed]

...
2 votes
2 answers
188 views

ADO.NET transaction handling

Please let me know your feedback around handling ADO.NET connection and transaction, especially when it comes the catch block. Any way I could improve? ...
5 votes
5 answers
726 views

Handle IDisposable objects

When I work a lot with objects, that implements IDisposable I am using this pattern, like shown here with a SqlConnection and a SqlCommand. ...
2 votes
0 answers
50 views

Queries within transaction [closed]

I am almost finished with my queries which are running inside transactions so it's everything or nothing... Could you please take a look if I am missing something or if everything is where it belongs? ...
0 votes
0 answers
893 views

WCF service architecture when SQL Server direct table access is not allowed

Part of my job is to maintain an old application written in Silverlight talking to a WCF service which in turn fetch/persist data into a SQL Server database and in a BI cube. Most of the security is ...
4 votes
1 answer
24k views

SQL server database access helper class

...
5 votes
2 answers
1k views

Interacting with a database

I've written my first class to interact with a database. I was hoping I could get some feedback on the design of my class and areas that I need to improve on. Is there anything I'm doing below that is ...
6 votes
2 answers
30k views

Transform DataReader to List<T> using reflections

I have implemented the code to convert datareader to list of objects. My intention was to not to use column name string literals while reading the datareader. ...
4 votes
3 answers
12k views

Simple SqlHelper which wraps ADO.NET methods

I am creating a simple SqlHelper which will simplify the ADO.NET method usage. Can someone please review this class for any issue or missing something? ...
4 votes
1 answer
9k views

Batch of SQL statements in a single query

I'm using the following query for multiple transactions. This is the scenario. Generate Salary (this is not in the scope of the query) I have employee attendance in ...
6 votes
2 answers
15k views

Multiple SQL statements in a single transaction

Using the following query I'm doing transactions with two tables ...
5 votes
1 answer
829 views

Build object from database without a discriminator column?

I currently have a basic application that has a database backing it. I originally connected to the database with Entity Framework, but my tutor has requested from me to recreate the functionality with ...
4 votes
2 answers
777 views

DAL Returns a collection of business objects in MVP

In Model View Presenter (MVP) pattern, it is said that our DAL always should returns business models. If I want to get a list ...
11 votes
2 answers
5k views

3 tier architecture ado.net application

I would like to develop a student management system with repository pattern using ado.net (no EF or MVC). I decided to create the model (business objects) and interfaces as one project "StudentModel"....
2 votes
2 answers
2k views

Database connection approach

We have recently started working in ASP.NET and starting a simple CRUD Web application in ASP.Net. Here is the approach we are following to connect to DB. Connection.cs ...
5 votes
1 answer
793 views

Hard-to-test 3 Tier Architecture

I'm having trouble testing some code. It's laid out in such a way that the business logic relies on the persistence layer. Some classes require that an object be saved to a database. Some classes re-...
5 votes
1 answer
7k views

Using model view presenter (MVP) in C# code

I'm a beginner to Model-View-Presenter pattern and I'm finding a way to use it in a sample application In my C# winforms application has a Employee Class and it ...