ado.net

Linq to SQL: Ammend command before submission to database

Is there a hook somewhere within Linq to SQL that would allow me to manually modify a command before it is sent to the database? Specifically, I am trying to introduce the WITH CHANGE_TRACKING_CONTEXT(@contextData) syntax whenever an insert/update/delete is applied to the database in order to be able to add additional information agains...

Using ADO.Net transactions within a TransactionScope?

Hi everyone, I've been reading about TransactionScope and had a question about its interoperability with ADO.Net transactions. Right now we have some data access methods that each call a stored proc and begin and commit their own individual transactions. Straighforward, boilerplate stuff, the methods look like this: sqlCommand = //cr...

how to try execute repeatly if command.ExecuteNonQuery() fails

how to try execute repeatly if command.ExecuteNonQuery() fails? ...

Pairing Email Transactions and ADO.NET Transactions

Is it possible to automatically link the sending of an email (using SMTPClient) in C# with an ADO.net transaction? So given the scenario of the sending of an email failing, the ADO.NET transaction will also fail and be automatically rolled back? Cheers ...

Viewing dataset contents without using dataset visualizer

In writing some tests for a project I'm working on, I found that the best way for me to get the data back I needed about whether the project was correct was to put results into an ADO.NET DataTable. I got sick of setting breakpoints and waiting for them to be hit so that I could use the DataSet Visualizer to see what my results were, an...

Implementing the gridview paging with database

I am binding dataset to a gridview,Which has 1000 records in it.As you know sending this entire dataset across a wire is costly. In the gridview i use paging which is set to 20 records per page. Since sending entire dataset is costly ,so i want to send 20 records at a time. How can i implement this? Is there any changes i need to do in...

Can DbParameter instance of same name and type be shared with multiple DbCommand instances?

Is it efficient or possible to share same DbParameter object with multiple commands? ...

how to manage multiple ado.net database connections from asmx Web Service

Since IIS assigns a worker thread for each request I've intention to create new object to serve each request. I have 2 questions: Is it efficient to create new object to serve each request? (is there even alternatice?) Is it thread safe, efficient and best practice to create new connection, and open&close it for each request like below...

Diagnosing WinForms Databinding problem

I'm learning Databinding from here http://www.akadia.com/services/dotnet_databinding.html I'm just updating the dataset and then updating the sql database using sqlDataAdaper.Update(); this.selectCommand = new SqlCommand(); this.selectCommand.CommandType = CommandType.Text; this.selectCommand.Connection = this.connection; ...

How to keep an audit/history of changes to the table

I've been asked to create a simple DataGrid-style application to edit a single table of a database, and that's easy enough. But part of the request is to create an audit trail of changes made, who made them, and the date/time. How might you solve this kind of thing? (I'll be using C# in VS2008, ADO.NET connected to SQL Server 2005, WPF...

How do i stop the The database file is locked exception?

I have a multithreaded app that uses sqlite. When two threads try to update the db at once i get the exception Additional information: The database file is locked I thought it would retry in a few milliseconds. My querys arent complex. The most complex one (which happens frequently) is update, select, run trivial code update/delete, c...

execution of Store procedure taking lot of time in asp.net

If i execute sp from query analyser then it take only max 4-5 sec. but same sp if i execute from asp.net ,using ado.net , using following code, it take 15-20 minutes. da.fill(ds); above statement takes 15-20 minutes. My sp return only max 15 records. Please tell me what to do? ...

Is SqlCommand.Dispose() required if associated SqlConnection will be disposed?

I usually use code like this: using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConn"].ConnectionString)) { var command = connection.CreateCommand(); command.CommandText = "..."; connection.Open(); command.ExecuteNonQuery(); } Will my command automatically disposed? Or not and I have to wr...

How to upload data to database with ADO.NET

Hey all, I have a web application that has a requirement to take data from an Excel workbook and load it to the database. I am using ADO.NET 2.0 and need to use DataSet/DataTable/DataAdapter/etc. to perform this task. We also have a requirement of verifying the data before it is uploaded and informing the user if there are any PK/FK/U...

Can a SQL Server database answer during a transaction?

I'm using .Net 2.0, ADO.NET, a dataset and data adapters to manage my data, and Microsoft SQL Server 2005 as database manager. I have an application that generates a great number of results (500K+) and saves them in a database. If one result generation fails, I would like to not save any of the results. So I put all the database inserts...

Would it be possible to extend the DataColumn.Expression

Could extension method be used for DataColumn.Expression to support for example the replace function ? If yes, any sample code available somewhere ? Thanks. ...

Resources for learning the ADO.NET Entity Framework CTP 2

Hello all, So here the ADO team announce CTP 2 of the Entity Framework. What resources are about to help me learn this? I've seen this which nicely describes earlier versions but it's the new version I'm specifically interested in. Thanks! ...

Parameterize the schema in a strongly-typed ADO.NET TableAdapter

Hey all, I'm trying to build a strongly-typed dataset in ADO.Net and am having a little trouble with one aspect of the TableAdapters. My query looks like SELECT * FROM testdict.ModuleVariable WHERE Module = ? My problem revolves around the testdict part. We use several different schemas to access our data (because of a multiplexed ...

Is ADO.Net Data Service Offline (Astoria Offline) dead? Any Plan B?

We are trying to convert out old school client server application into a N-Tier application with synchronization and offline support using all Microsoft technology (we are a total .Net and SQLServer shop). We want to focus on writing business logic instead of spending time on pluming, so we are going to use as much existing Microsoft pl...

create three stored procedures (select/update/insert) per table or as needed?

using asp.net, sql server 2008, winserver2003 we have about 10 tables with about 20 fields each... we have about 30 web forms where each form uses some variation of fields from some/all tables... each form has its' own dataset depending on the tables it uses. However, to create that dataset, a Select * stored procedure is called on e...