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
220 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
114 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
1 answer
144 views

Improvements to data access layer

...
  • 31
2 votes
1 answer
826 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
159 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
324 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 ...
3 votes
2 answers
3k 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 ...
2 votes
1 answer
800 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 ...
9 votes
4 answers
3k 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 ...
1 vote
1 answer
87 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
725 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
100 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 ...
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 ...
1 vote
0 answers
499 views

Simple AuditLog

I am using ADO.NET in my project and I want to have a simple AuditLog. I have below Codes for that but I wounder to know is ...
2 votes
1 answer
182 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
3k 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 ...
  • 31
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 ...
  • 125
1 vote
3 answers
139 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
2 answers
100 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 ...
  • 31
1 vote
0 answers
32 views

ADO.NET DataRow auto updater

I'm currently learning ADO.NET and I've written a small auto updater to move data automatically between a class and a datarow. General usage would be to create a class and mark the DataRow 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 ...
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: ...
  • 231
4 votes
1 answer
935 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 ...
  • 143
6 votes
3 answers
11k views

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

...
  • 85
2 votes
2 answers
180 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? ...
  • 155
4 votes
1 answer
788 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 ...
5 votes
5 answers
724 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. ...
  • 150
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? ...
1 vote
0 answers
857 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 ...
  • 1,786
4 votes
1 answer
23k views

SQL server database access helper class

...
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
8k 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 ...
  • 1,743
6 votes
2 answers
12k views

Multiple SQL statements in a single transaction

Using the following query I'm doing transactions with two tables ...
  • 1,743
6 votes
2 answers
29k 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
2 answers
767 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 ...
  • 1,743
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"....
  • 277
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 ...
user avatar
5 votes
1 answer
775 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-...
  • 153
5 votes
1 answer
6k 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 ...
  • 1,743
3 votes
2 answers
144 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 ...
  • 336
5 votes
1 answer
828 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 ...
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 ...
  • 1,621