.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Strongy typed datasets, tableadapters and transactions

Posted By:      Posted Date: October 08, 2010    Points: 0   Category :ASP.Net

I'm using a stronly typed dataset built with the Visual Studio dataset designer for a .Net 2.0 application (cannot move above 2.0 unfortunatly)

On a simple level my database has two tables, Persons and Addresses. An Address record has a foriegn key to a Person from the Persons table.

When a new Person is created an Address is also inserted for the Person, I'd like this to be in a single transaction that can be committed or rolledback using the tableadapters.

This approach seems very close: http://www.codeproject.com/KB/dotnet/transactionta.aspx

This method is failing when the dataset is set to Refresh records on Insert/Update, but I need this Refresh to pull the ScopeIdentity and update the dataset so I know the new ID of a created record in Persons or Addresses.

Any ideas?

View Complete Post

More Related Resource Links

Typed DataSets in .NET

we can specify the data type when we create a DataColumn for a DataTable. This is to enforce the runtime type-safety for the column so that only data of specified data type can be stored in the column

Data Points: Efficient Coding With Strongly Typed DataSets


Someone once said to me that the hallmark of a good developer is the desire to spend time efficiently. Developers are continually pursuing ways to make coding easier and faster, and to reduce the number of errors.

John Papa

MSDN Magazine December 2004

Typed DataSets/Connection Pooling


 Hey all,

I've got an ASP.net application that has about 100-120 sites connecting to punch in/out in the beg of shift, lunch, and end of shift. I've found that the app gets slow/non-responsive during peak times. Also, I'm noticing that the app will throw Oracle End of File Communication errors periodically during the day. I'm using Strongly typed Datasets to interact with the DB. I have a couple of questions:

1. What type of cleanup should I be performing? Should I be closing/disposing the connection or Adapter instance or is this handled internally by the dataSet?

2. I have the connection pooling set to the default - 100. Should I increase this or will this cause other performance issues? How would one test to see if the connection pool is maxing out? Could this be causing the Oracle EOF (ORA-03113) errors?


How to create strongly typed datasets with access parameter queries



How can you create strongly typed datasets using an access database against access select statements that use parameters?

The problem is VS.Net doesn't allow select queries with parameters to be dragged onto a form, it only allows access queries without parameters!

I also tried the dataadapter wizard, but again it only allows me to select queries without parameters?

Many thanks in advance


asp.net insert into 3 related tables using three tier architecture and typed datasets

I am using ASP.NET (C# and sql server express 2005) for my web application project. I have three related tables.I want to do an insert using typed datasets,tableadapters and three tier architecture.I wish to know how to do simultaneous inserts in 3 tables.So i wish to insert a row in first table and get its primary key.Same with the second table.I will use the primary keys of those first two tables to do the insert in the third table.How can i accomplish this using formview control and what methods should i use??Please give me suggestions.thanks in advance for reading this. I really appreciate it.

Problem with SCOPE_IDENTITY in strongly typed datasets



I am developing an ASP.NET site and I am using strongly typed datasets and I am generating them automatically in Visual Studio 2008. I have been using TransactionScope to be able to use several table adapters from different datasets and update them in one transaction. When I create a new row, I use the update method in the table adapter to create new posts. The update method takes a dataset, datatable or a row as argument making them very easy to work with. After I have updated a row, I have generated a ExecuteScalarGetIdValue() call to get the latest inserted ID value. I use "SELECT SCOPE_IDENTITY" and it gives me an exception. When I try the query builder this SELECT SCOPE_IDENTITY is returning NULL. When I ask it in SQL Management Studio SQL Query window it returns a correct value. How can I get the correct value from the table adapter?

        id = this._event.ExecuteScalarGetIdValue();



      return true;

 Best regards, Janhe

Autogenerated strongly typed datasets: change database



I have a data access layer in my application where I put all my *.xsd files (strongly typed datasets) that are autogenerated using Visual Studio 2010.

To be able to change target database I do the following manually in Visual Studio. Then I recompile and publish to web server.


1. Change database namn in connectionstring in Settings file under Properties in my DAL class library.

2. Find and replace database namn in all occureances of "DbObjectName="DBNAME.dbo.".

3. Find and replace database namn in all occureances of "DataSourceName="DBNAME.dbo.".


This seems to work but is not an optimal procedure so my question is:

There must be a better way, can I do this programmatically?


Best regards, Janhe

Generate strongly typed datasets from xml


I am following an articles about strongly typed datasets in vs.net. After creating my xml file and creating the schema file, when I right click to "generate dataset, that option is not available in Visual Studio 2005. How do I do this?


Wrapping Multiple TableAdapters inside Transactions


Problem :

In my project's earlier version I used Stored Procedures (SPs) & directly used them inside presentation layer. SP contains multiple Insert & Update queries for multiple tables. 

Now I have decided to use a DAL(Typed DataSets & TableAdapters)

How can i use the same SPs with TableAdapters or If not possible how to wrap Multiple TableAdapters inside Transactions.

1 more thing in my earlier version i was using Transaction in SPs & Presentation Layer.

Introducing ADO.NET and the Typed DataSet

In reviewing the applications it seemed everything they were doing involved database reads, writes, and manipulation. The development staff had been reviewing the articles and code samples for ADO.NET. They had spent many years refining their existing ADO based infrastructure and perfecting their use of ADO

UnTyped DataSets and Strongly Type DataSets

We all are use datasets as a means of carrier of data from one layer to another. Most of the time we are using weakly typed datasets. In this article I will explain the differences between weakly typed datasets and strongly type datasets

Create and Use a Typed DataSet by Using Visual C# .NET

This article shows you how to create and use a typed DataSet in a small Web application. Typed DataSets, which inherit from the DataSet class, create first-class members of a DataSet's DataTables and DataColumns, yielding the many benefits that come with the use of strong typing.

Introduction to strongly Typed Data Sets

This article teaches how to create a strongly-typed dataset class library in your C# database applications. Our objectives are as follows:

.Learn what an strongly-Typed Data Set is
.Let Visual Studio Create a ST Data Set
.(Semi)Manually create a ST Data Set using XSD (Xml Schema Definition)

The Polyglot Programmer: ACID Transactions with STM.NET


STM.NET allows developers to mark their code with ACID-style transactional semantics, and leaves the grunt work of managing locks to the underlying environment.

Ted Neward

MSDN Magazine January 2010

Foundations: Easily Apply Transactions To Services


Managing state and error recovery using transactions is the topic of this month's installment of Foundations.

Juval Lowy

MSDN Magazine January 2009

Transactions: Build Scalable Systems That Handle Failure Without Losing Data


Systems that handle failure without losing data are elusive. Learn how to achieve systems that are both scalable and robust.

Udi Dahan

MSDN Magazine July 2008

NTFS: Enhance Your Apps With File System Transactions


Presented here is an overview of Transactional NTFS and how it revolutionizes transactions.

Jason Olson

MSDN Magazine July 2007

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend