Tag: ado.net

Do ADO.Net DataTables have indexes?

I am using VSTS 2008 + C# + .Net 3.5 + SQL Server 2008 + ADO.Net. If I load a table from a database by using a DataTable of ADO.Net, and in the database table, I defined a couple of indexes on the table. My question is, whether on the ADO.Net DataTable, there is related […]

TransactionScope helper that exhausts connection pool without fail – help?

A while back I asked a question about TransactionScope escalating to MSDTC when I wasn’t expecting it to. (Previous question) What it boiled down to was, in SQL2005, in order to use a TransactionScope, you can only instance and open a single SqlConnection within the life of the TransactionScope. With SQL2008, you can instance multiple […]

Why is my SqlCommand returning a string when it should be an int?

I have a query that should always be returning a single int. I have now logged it returning a string entirely unrelated to what it should be. We’ve been getting some random FormatExceptions that we’ve tracked down to several database queries. After some additional logging, I found that, this morning, the query below returned the […]

Error inserting data using SqlBulkCopy

I’m trying to batch insert data into SQL 2008 using SqlBulkCopy. Here is my table: IF OBJECT_ID(N’statement’, N’U’) IS NOT NULL DROP TABLE [statement] GO CREATE TABLE [statement]( [ID] INT IDENTITY(1, 1) NOT NULL, [date] DATE NOT NULL DEFAULT GETDATE(), [amount] DECIMAL(14,2) NOT NULL, CONSTRAINT [PK_statement] PRIMARY KEY CLUSTERED ( [ID] ASC ) WITH (PAD_INDEX […]

Need to get empty datatable in .net with database table schema

What is the best way to create an Empty DataTable object with the schema of a sql server table?

C# – Inserting multiple rows using a stored procedure

I have a list of objects, this list contains about 4 million objects. there is a stored proc that takes objects attributes as params , make some lookups and insert them into tables. what s the most efficient way to insert this 4 million objects to db? How i do : — connect to sql […]

How to track changes in many SQL Server databases from .NET application?

Problem: There are a lot of different databases, which is populated by many different applications directly (without any common application layer). Data can be accessed only through SP (by policy) Task: Application needs to track changes in these databases and react in minimal time. Possible solutions: 1) Create trigger for each table in each database, […]

Using TransactionScope around a stored procedure with transaction in SQL Server 2014

I am using C# and ADO.Net with a TransactionScope to run a transaction in an ASP.Net app. This transaction is supposed to save some data across multiple tables and then send an email to subscribers. Question: is it a valid use of TransactionScope, when it includes a call to a stored procedure that has its […]

SqlDataAdapter.Fill() within a SqlTransaction – is this a bad practice?

Since I have a “DB util” class with a DataSet QueryDB(string spName, DBInputParams inputParams) method which I use for all my calls to the database, I would like to reuse this method in order to support transacted calls. So, at the end I will have a SqlDataAdapter.Fill within a SqlTransaction. Will this be a bad […]

How to Prepare an ADO.NET Statement which includes an NText (clob) parameter

I’m updating an existing application which uses a factory to build prepared statements, and then execute them later, which works for the rest of the system, but I’ve been tasked with adding a call to a statement which uses an NText, and I cannot figure out how to properly prepare the statement. I am getting […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.