ADO.NET :: Using TransactionScope In BLL With TableAdapters As DAL?
Dec 26, 2010
I have two BLL classes ItemsBLL & BalanceBLL. When ever a new Items gets Added to Items table few details needs to be added to Balance Table.
I am using the following code to perform the operation, is this code efficient or something needs to be changed.
The function that needs to be checked is the Insert function in ItemsBLL Class.
[Code]....
Is this function effective?
[Code]....
[Code]....
View 11 Replies
Similar Messages:
Mar 11, 2011
I have a Crystal report with a datasource of tables from two different typed datasets.
Two of the tables come from one typed ds, and one the other ds. They logically share a common key.
In the webform backend of the crystal report, I populate datatables using the methods of the respective tableadapters. Every time I run the report, it is prompting me for username and password info, which it then doesn't accept. The code to populate the dataset in the backend is as follows:
[Code]....
View 3 Replies
Apr 1, 2010
i've created a dataset, and created inside it a datatable and its table adapter.
when i try to reference the table adapter in a .cs class i get an error message that i'm missing some namespace:
Compiler Error Message: CS0246: The type or namespace name 'DataSet1TableAdapters' could not be found (are you missing a using directive or an assembly reference?)
View 2 Replies
Jan 4, 2010
environment: W7ULT64, VS2008, SQL Express.I'm changing from an OLD (MSAccess, VS 2003) environment to SQL exp / VS2008!
Now I'm stuck with adding 'DataRows' using the 'DataSet.xsd'.
PS: the very last peace of code is just to test that I'm able to read the DB! I.e. I assume it's NOT a SQL issue!
Problem: (Vs2008)With below code I'm able to fill 'newRow' with the correct values! But because I do NOT have an 'add' mechanism
the '.update(newRow)' doesn't do anything (also no error!)
Problem: somehow I'm NOT able to find a way (intellisense!) to create the appropriate/correct statements to .add(newRow).
Code in VS2008:
Dim TherapieAdapter As New DataSetTherapieTableAdapters.therapieTableAdapter
Dim values As New DataSetTherapie.therapieDataTable
Dim newRow As DataSetTherapie.therapieRow = values.NewtherapieRow()[code]....
View 2 Replies
Mar 4, 2011
I have a requirement whereby I either have to perform and update or an insert on 1 table inside a transactionscope
There are 3 table in total, 2 will always be an insert, but 1 could be either an update or insert depending if some data already exists a foreign key relationship exists between all 3 tables (not on the same column though)
heres my code
[Code]....
[Code]....
View 2 Replies
Nov 9, 2010
I will explain the my current yet simple architecture of my application(s). At the moment I have my main web application as a separate project. I then reference the CoreBLLDAL (Business Logic and Data Access) Project so that several projects can have access to the BLL/DAL Project.
Within the CoreBLLDLL Project I use TableAdapters for my DAL.
I have just upgraded to VS2010 and I would like to make use of the Config Transforms, allowing me to have a separate web.config for test and production - however, TableAdapter get the connection string from the Settings.settings file.
How can I change the TableAdapters to get the connection string from the app/web.config file? I read that you can change this within the designer file for the TableAdapters by using ConfigurationManager, however, I tried this but I do not have access to the ConfigurationManager namespace. I presume this is because the project is a class library and not a web application - I am not too sure.
View 2 Replies
Jan 9, 2010
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.
View 5 Replies
Feb 3, 2010
Im running an ASP.NET MVC application hosted with Mosso, there are telling me that they cannot enable DTC because they run everything in medium trust.So when executing code that references: TransactionScope I get the following error. The transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D024)
Is there anyway to get around this?
View 1 Replies
Feb 23, 2011
[Code]....
Now,
1. If In transaction scope if 1st Transaction is commited, buting 2nd one exception occurs and it is rolled back
2. Any other exception occurs, after 1st transaction is completed/commited
Here, explicit transactions are used. In both cases does all transactions in the scope are revert back? What are the possiblities here?
View 7 Replies
Dec 21, 2010
we have a asp.net webforms app using NHibernate. Here are some specifics:We need Distributed Transactions because we write to the database as well as to a queue.Because this is a web app, we use the recomended Session-in-view pattern. We have a HTTPModule that opens the NHibernate session on the BeginRequest event and closes it on EndRequest.Within the flow of a request, we have several separate moments where we need to do transactional work. For this, we use TransactionScope.So basically, what happens is this (pseudocode):
using(var session = sessionFactory.CreateSession()){
using(var tx1 = new TransactionScope(){
//work work work
[code]...
View 2 Replies
Sep 4, 2010
I am working on Sales application. In database i have SalesOrderHeader & SalesOrderDetail tables. They are almost typical Adventureworks db tables.
How to insert data in both tables using TransactionScope so if any of the record from the two tables generate error complete transaction roll-back.
One thing more I am using TableAdapters, My initial concept was inserting record in SalesOrderHeader, get SalesOrderId using Scope_Identity & bulkInsert Records to SalesOrderDetail using TransactionScope.
View 1 Replies
Aug 24, 2010
I'm using VS 2008 and SQL 2008.
I have created the tables and the stored procedures in SQL 2008.
In VS 2008, I created DataSet1.xsd in App_Code and created the connectionString in web.config file.
Then when I go into the DataSet1.xsd and try to add a TableAdapter, strange things happened.
First I chose the data connection, then selected "Use existing stored procedure", then there was nothing listed in the dropdownlists (in Select, Insert, Update, or Delete).
I'm sure the connectionString is correct because if I choose "Use SQL statement" and type in a "select * from mytable1", the TableAdapter can be created without any problem.
View 1 Replies
Apr 29, 2010
I have code that is supposed to do some database operations and then send an email through local iis smtp virtual server. All within one TransactionScope. It looks like
[Code]....
The second one where I use something similiar is
[Code]....
I want to notice that these events fire in the sequence they are shown. Now when there's an error, the db operations are rolled back, but the mail is sent anyway. I'm using Windows XP SP3, IIS 5.1, .Net 3.5, Visual Studio 2008. If I'm correct, TransactionScope uses MSDTC, right? I couldn't find anything about MSDTC working with smtp. Should it even work?
[code]....
View 2 Replies
Jul 24, 2010
Suppose say I am doing a couple of operations.
First a delete and then an insert.
Now, these two operations are done with two different connections (say con1 and con2). Both these connections are enlisted in the same TransactionScope.
Before the delete/insert operations the connections are opened and immediately closed.
So, now if the insert fails, then how is the delete rollbacked since con1 has been closed?
View 1 Replies
Jun 18, 2010
I'm writing some merge functionality in C# asp.NET MVC2. I am also using using Linq2SQL.
I have a block of code which calls two services, MessageService and UserService. These both in term call their appropriate repositories and make the amendments to the db. Each repository declares it's own instance of the repository so I'm thinking this will escalate the following code to DTC . The code is called from the AccountService, is this going to work at this level? And also is it bad practise to declare the DataContext at the top of every repository or should I pass the object around somehow?
//Run the merge
try
{
using (TransactionScope scope = new TransactionScope()) [code]....
View 2 Replies
Feb 18, 2011
I m using transactionscope and there was no problem until my domain changed.When it hits the scope7, it inserts the data and starts all over again and inserts for the second time.
Here is my sample code:
Using scope7 = New TransactionScope(TransactionScopeOption.RequiresNew)
Dim comm As New Data.SqlClient.SqlCommand("INSERT INTO ABC (ID, AID, Type) VALUES (@ID, @AID, @Type)", conn)
comm.Parameters.AddWithValue("@ID", TaskID)
comm.Parameters.AddWithValue("@AID", FormID)
comm.Parameters.AddWithValue("@Type", FormType)
conn.Open()
comm.ExecuteNonQuery()
scope7.Complete()
View 1 Replies
Feb 20, 2010
I am confused about why I would need to wrap the DataContext's SubmitChanges within a transactionScope when modifying multiple tables. I was under the impression that the DataContext would track these changes and would therefore create its own transaction if need be.
In other words, if a change was made to update table A, B and C or if I made changes to 10 out of 20 items in a collection of rows, that the datacontext would track these changes and create its own transaction. If that is correct then why have I seen examples that wrapped these types of updates in a TransactionScope?
View 4 Replies