Latest developer linksBookmark and Share
 
HomeThis WeekTop MonthTop AlltimeSearchRegisterFAQ
  
 
Submit Your Link
Please login to submit your Link
 

Having problems using SqlServerCE 4.0 & Transactions / TransactionScope

Posted: Jan/22/2011   By: nikhil   Points:15   Category: .NET  - ASP.Net    Views:187   Vote Up (0)   Vote Down (0)    

Hi folks,

I've got some code which is throwing an exception when I use this against SqlServer CE 4.0 & within a TransactionScope. First, the code, then the error.

 

// Arrange.
// ... some stuff ...

// Act.
using (new TransactionScope())
{
 order.Name = name;
 _orderRepository.Save(order);
 _unitOfWork.Commit(); // <-- this works 100% fine.

 // Assert.
 var updatedOrder = _orderRepository
 .Find()
 .Where(x => x.OrderId == 1)
 .SingleOrDefault(); <-- // this throws the exception.

 Assert.IsNotNull(updatedOrder);
 Assert.AreEqual(name, order.Name);
}

 

The exception error is:- System.Data.EntityException: The underlying provider failed on Open. ---> System.InvalidOperationException: The connection object can not be enlisted in transaction scope.

So the first save/commit works fine. I can see the data getting passed across to the db, using EFProf as the profiler...

 

enlisted object context in distributed transaction with isolation level: Serializable


insert [Orders]
 ([Name],
 [CreatedOn],
 [SentOn],
 [UserId])
values('New Order Name - Pew Pew Pew' /* @0 */,
 '2011-01-20T16:30:00.00' /* @1 */,
 null,
 1 /* @2 */)


select [OrderId]
from [Orders]
where [OrderId] = @@IDENTITY


rollback transaction

 

So it failed to pass ANY data across the wire for the 2nd database request (ie. the updatedOrder code), to the sdf ... which is why there's no 2nd select statement there. And of course, the rollback will be called because the transaction failed to end with a commit.

Can someone help me out here?

 

 


-Pure Krome-

View Complete Post


Comments:
Be the first to comment this post.
 
Post Comment
Please login to post your comment
More Related Resources

problems with ajax.actionlink

  

hi,

  i have this razor page...

            <div id="grid">  
                @{var gridQuest = new WebGrid(source: Model.Domande, defaultSort: "IdRisorsa", rowsPerPage: 10);}   
                @(gridQuest.GetHtml(tableStyle: "grid", headerStyle: "head", alternatingRowStyle: "alt",
                    columns: gridQuest.Columns(
                        gridQuest.Column("Domanda.Testo""Testo"),
                        gridQuest.Column("Domanda.RispostaRandom""Random"),
                        gridQuest.Column("Domanda.Punteggio""Punteggio"),
                        gridQuest.Column("Domanda.SommarioRisposte""Risposte"),
                        gridQuest.Column(format: (item) => Html.ActionLink("Cancella""Delete""Domande"new { domanda = item.DomandaNo, questionario = Model.CorsoRisorsaNo }, null)),
                        gridQuest.Column(format: (item) => Ajax.ActionLink("Modifica""EditDomanda"new { id = item.DomandaNo }, new AjaxOptions { UpdateTargetId = "domandaModifica" }))))
                  )
            </div>
        </td>
        <td>
        <div id="domandaModifica"></div>
        </td>

and in the template i have
    <script src=
                         

Problems Passing ViewModel with data from View to Controller

  

Ok, here is my problem.  I am trying to pass a view model of mine, which has multiple list in it, to my view.  Then in my view i need to edit the different list.  Then on my post i need to save the edits.  Although, when i pass my viewmodel back to my post, it is empty! Can somebody explain what i am doing wrong?

Controller

       

public ActionResult ManageNewsArticles()
        {
            NewsViewModel newsViewModel = new NewsViewModel();

            newsViewModel.ListBreakingNews = db.NewsArticles.Where(n => n.PageSetupID == 1).ToList<NewsArticle>();
            newsViewModel.ListMainArticle = db.NewsArticles.Where(n => n.PageSetupID == 2).ToList<NewsArticle>();
            newsViewModel.ListSubNews1 = db.NewsArticles.Where(n => n.PageSetupID == 3).ToList<NewsArticle>();
            newsViewModel.ListSubNews2 = db.NewsArticles.Where(n => n.PageSetupID == 4).ToList<NewsArticle>();
            newsViewModel.ListSubNews3 = db.NewsArticles.Where(n => n.PageSetupID == 5).ToList<NewsArticle>();

            return View(newsViewModel);
        }

        [HttpPost]
        public ActionResult ManageNewsArticles(NewsViewModel newsViewModel)
        {
            if (ModelState.IsValid)
            {
                db.SaveChanges();
                return RedirectToAction("Admin");
            }
            
            return View(newsViewModel);
        }



here is my View

   
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<TrueNews.ViewModels.NewsViewModel>" %>

    <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
        Manage News Articles
    </asp:Content>
    
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    
        <h2>Manage News Articles</h2>
    
        <% Html.EnableClientValidation(); %>
    
        <% using (Html.BeginForm(Model)) {%>
            <%: Html.ValidationSummary(true) %>
            
            <fieldset>
                <%: Html.EditorForModel(Model) %>
                <p>
                    <input type="submit" value="Save" />
                </p>
            </fieldset>
    
        <% } %>
        
        <div>
            <%: Html.ActionLink("Back to Admin Controls", "Admin") %>
        </div>
    </asp:Content>



NewsViewModel

   
public class NewsViewModel
        {
            public List<NewsArticle> ListBreakingNews { get; set; }
            public List<NewsArticle> ListMainArticle { get; set; }
            public List<NewsArticle> ListSubNews1 { get; set; }
            public List<NewsArticle> ListSubNews2 { get; set; }
            public List<NewsArticle> ListSubNews3 { get; set; }
        } // End of Class



Problems moving Drupal from WebMatrix to hosting

  

I got the first beta of WebMatrix, downloaded Drupal, and got a site more or less going.  I then tried to move it to two different hosts - first the IIS server running on my own domain controller, then to my hosting service.  I dumped the DB with mysqldump, and imported it to the databases running on each server. Then I ftp'd the code and configuration files to both servers, and made appropriate configuration changes (primarily the mysql connect string).

On both servers I have the same problem: The site comes up in its home page and looks great, but as soon as I log in as the site admin, I get a 404 (not found) error.  Since it looks like virtually everything in Drupal is driven from the database, I really haven't the faintest idea where to start debugging this.

Can anyone give me any hints?


Problems with Null values and Radiobuttonlist

  

Hi guys,

 I've been trawling various forums and racking my brain over this one for the last couple of days. I have a problem with a databound radiobuttonlist inside a formview, as when a new record is created the value for the field bound to to radiobuttonlist is null which causes an error because the value is ot in the list of items. I could add an extra item to handle this, but I can't think of a way to make it invisible so it looks silly, and I could add a default value to the DB field, but I want to make sure the selection has actually been made by the user. The only way around it I can think of at the moment is to create a server control based on the original, or remove the databinding and do it manually.

Any help would be most appreciated.

 As an aside, I've seen this type of question a number of times but haven't found a satisfactory answer and a couple of days ago I came upon an ASP site with radio buttons where the first item in the list was something like "Please select an option from below" and was pre-selected. I though that looked a little silly too.


problems with selectNodes

  

Hi,

I am using someone elses webservice which requires a xmlnode as input so ive mimicked what it requires and passed it in - effectively...

FuncCall(XmlNode xData)

Now I have breaked it at a statement like this:

XmlNodeList xBys = xData.SelectNodes("/by");

When it is called by the program it was intended for this is the content of xData:

    <budget_in>Currency</budget_in>
    <curr_id>1</curr_id>
    <header_row>5</header_row>
    <report_date>2010-12-13T00:00:00</report_date>
    <dimensions>
      <dim_1>RESOURCES</dim_1>
    </dimensions>
    <by>
      <by_id_1 cell="A6" id="62"><![CDATA[Stephen Hill]]></by_id_1>
      <periods>
        <period start="2007-08-01T00:00:00" cell="B6">
          <value>382.5</value>
        </period>
        <period start="2007-09-01T00:00:00" cell="C6">
          <value>67.5</value>
        </period>
        <period start="2007-10-01T00:00:00" cell="D6">
          <value>517.5</value>
        </period>
      </periods>
    </by>


As you can see the 'by' is an immediate child and so is caught in the selectNodes. However I pass this in:

<budget_in>Days</budget_in>
<curr_id>1</curr_id>
<report_date>13/12/201009:53:14</report_date>
<dimensions>
 <dim_1>Activity</dim_1>
 <dim_2>Department</dim_2>
 <dim_3>Charge Rate</dim_3>
</dimensions>
<by>
 <periods>
  <period start="01/01/2011 00:00:00"><value>2.5</value></period>
  <period start="01/02/2011 00:00:00"><value>7.4</value></period>
  <period start="01/01/2010 00:00:00"><value>5.5</value></period>
  <period start="01/02/2010 00:00:00"><value>1.4</value></period>
 </periods>
 <by_id_1 id="10" />
 <by_id_2 id="10" />
 <by_id_3 id="22" />
</by>
<hours_in_day>7.5</hours_in_day>

Which xml wise is the same I thought but the selectNodes("/by") has a count of zero? And I cant figure out why? Any ideas?

if I do "//by" they both obviously work

If I look at the childNode count for mine it is 6 which means that the <by> is a immediate child node. I cant change the webservice to "//by" unfortunately

Would appreciate some suggestions on this connudrum

Thanks

Kal

 


Various problems with AKS

  
Hello Everyone,

I recently installed the HiSoftware AKS. The HCCE seems to work well, (essentially a big find a replace) which got me from 400 validation errors to 40! Sweet! But I'm noticing some major problems. In addition to the HCCE I installed the WebPart Smart Adapter which I think might be the source of my problems, but I can't be sure. 

I'm posting these here in hope that there is some brave soul out there that has run into these and could help me out. I would be very grateful! I can't find information on these issues anywhere. 

-------------------------------------------------------------------------------------------------------
1. Custom web part properties seem to be global now, rather than instance specific:

I created a custom web part a while ago that is intended to be placed on numerous pages across my MOSS 2007 site. 

On each page I change a custom property so that the web part displays something different on each page. 

This worked great up untill recently. Now when I change the properties on one part it now changes on all them across the site, I loose my customizations! 
-------------------------------------------------------------------------------------------------------
2. Info path xmlformview web part won't load .xsn's, javascript errors!
-------------------------------------------------------------------------------------------------------
3. My master page seems to break with sharepoint menu data getting thrown around

The username in the login menu for some reason get's thrown outside of the <html> tags which naturally is invalid XHTML but worse it breaks the entire layout brutally in IE7. As IE7 freaks out if anything is outside of the <html> tags.




- Brendan

Problems Installing AKS 1.1 on Windows Server 2008 x64bit

  
Hi all, 

I am trying to install AKS 1.1 (not 2 or 1.0 cuz thats the only release i was able to find on aks.hisoftware.com) on a windows server 2008 x64bit machine. 
 
the toolkit installs in this location: C:\Program Files (x86)\HiSoftware\AKS  .... but nothing in the 12\template\features folder.

the script install_AKSFEAT.bat refers to a feature name "AKS", but i cannot see the feature anywhere in the features folder, and i cannot see a WSP pacakge to deliver this feature to sharepoint!

i event tried to look for the feature manifest to reverse engineer the works of the feature but no luck finding this file in the AKS install folder.

what am i missing here? how can i get AKS 1.1 to install properly and the feature to activate? please HELP!!


- mutaz

Problems ACTIVATING AKS Feature

  

I get the message below when attempting to active the Accessibility Kit for SharePoint feature on my Site.

 

Failed to instantiate file "aks_bl_Navbar.JPG" from module "Images": The specified list does not exist.

 

This occurs on a default "MySite" but not in a default "Publishing Site" ... Anyone know what the problem is?


Problems with Sharepoint search returning DisplayInAdminUI error

  

We have a farm with two internal WFEs (“WFE_INT_A” and “WFE_INT_B”), one firewalled (“WFE_EXT”), a SQL and an Index server . The farm is hosting two MOSS sites. The site (“Site_B”) we’re currently working with has custom master and layout pages. The WFEs are not load balanced.

1.       CA is on WFE_INT_A.

2.       Site_B, say, is hosted on WFE_INT_B: the IP is set on WFE_INT_B, IIS on WFE_INT_B is set to that IP on port 80. AAM has been set with a URL  point to the IP.

3.       We set up a second SSP, "SSP_B", to handle search, and limit it to only Site_B.

Before we set the IP and AAM to direct users to WFE_INT_B, search was working great. Afterwards, when we set the IP to read the site from WFE_INT_B, we began to get errors.

I posted a couple questions to MSDN and followed the recommendations, but continue to get errors.

Since Search works fine for Site_A, we deleted SSP_B, which merged Site_B back into the primary SSP.

·         We are currently able to view search results on _layouts/OSSSearchResults.aspx , though these results combine data from Site_A and Site_B, even though we’ve tried to scope them to one site. To be exact, Site_A only gets results for Site_A, but Site_B combines results of Site_A and Site_B.

·        

Audience Problems - Claims Web App with AD

  

Hello

 

I have a new Sharepoint farm that is configured using Claims authentication and I'm having trouble complining audiences. I have read a few places that you cannot use memeberof audiences against AD group memebrships if you are using Claims authetication. I tried configuring a few audeinces based upon user profile properties. They complie succesfuly, but no memeberships.

Has anyone configured audiences on a webapp with claims authentication ?

 

 


 
Categories:
.NET
Java
PHP
C/C++/VC++
HTML/XML
SAP
MainFrames
Data Warehousing
Testing
MySQL
SQL Server
Oracle
Javascript/VB Script
Others
Login
 
 
 
 
 Forgot password
 Contact Us   Terms Of use   Share your knowledge