Search Results

Search found 15 results on 1 pages for 'molgan'.

Page 1/1 | 1 

  • The data reader returned by the store data provider does not have enough columns

    - by molgan
    Hello I get the following error when I try to execute a stored procedure: "The data reader returned by the store data provider does not have enough columns" When I in the sql-manager execute it like this: DECLARE @return_value int, @EndDate datetime EXEC @return_value = [dbo].[GetSomeDate] @SomeID = 91, @EndDate = @EndDate OUTPUT SELECT @EndDate as N'@EndDate' SELECT 'Return Value' = @return_value GO It returns the value properly.... @SomeDate = '2010-03-24 09:00' And in my app I have: if (_entities.Connection.State == System.Data.ConnectionState.Closed) _entities.Connection.Open(); using (EntityCommand c = new EntityCommand("MyAppEntities.GetSomeDate", (EntityConnection)this._entities.Connection)) { c.CommandType = System.Data.CommandType.StoredProcedure; EntityParameter paramSomeID = new EntityParameter("SomeID", System.Data.DbType.Int32); paramSomeID.Direction = System.Data.ParameterDirection.Input; paramSomeID.Value = someID; c.Parameters.Add(paramSomeID); EntityParameter paramSomeDate = new EntityParameter("SomeDate", System.Data.DbType.DateTime); SomeDate.Direction = System.Data.ParameterDirection.Output; c.Parameters.Add(paramSomeDate); int retval = c.ExecuteNonQuery(); return (DateTime?)c.Parameters["SomeDate"].Value; Why does it complain about columns? I googled on error and someone said something about removing RETURN in sp, but I dont have any RETURN there. last like is like SELECT @SomeDate = D.SomeDate FROM .... /M

    Read the article

  • Can't access stored procedure from entities

    - by molgan
    Hello I'm using entity framework that came with 3.5sp1. And in visual studio I have imported function so it shows under "Function Imports" in the "Model Browser". I have assigned all rights to the user that connects to the database. But it doesnt show in the intellisense when I type "_entities.", only my other entities shows there. I opened the designer file and couldnt find it there either..... The stored procedure should return a scalar datetime value, and not an "entity" What might be wrong here? /M

    Read the article

  • LINQ If .Any matches .Any

    - by molgan
    Hello I have 2 string arrays, and I would like to return if any of them exists in _authRole array. How is that done? string[] _userRoles = userdata.Split(','); string[] _authRoles = AuthRoles.Split(','); bool isAuthorized = _authRoles.Any(_userRoles ??); /M

    Read the article

  • Case Order by using Null

    - by molgan
    Hello I have the following test-code: CREATE TABLE #Foo (Foo int) INSERT INTO #Foo SELECT 4 INSERT INTO #Foo SELECT NULL INSERT INTO #Foo SELECT 2 INSERT INTO #Foo SELECT 5 INSERT INTO #Foo SELECT 1 SELECT * FROM #Foo ORDER BY CASE WHEN Foo IS NULL THEN Foo DESC ELSE Foo END DROP TABLE #Foo I'm trying to produce the following output: 1 2 3 4 5 NULL "If null then put it last" How is that done using Sql 2005 /M

    Read the article

  • Entity framework, adding custom entity to diagram

    - by molgan
    Hello I'm using the entity framework that comes with 3.5sp1, and I'm trying to add a custom entity that I will propulate with searchresults from a stored procedure. But I have problems with the designer....... when I pick "Add + Entity" and give it a name, and hit save, the whole diagram stops working...... blah entities namespace could not be found..... all the other entities have lost its reference or summet. Works when I add a "table" to it that exists in database. But when custom it screws everything up. How should I fix this? I've imported the function, I just need to add an entity for it... I've read http://blogs.microsoft.co.il/blogs/gilf/archive/2009/03/13/mapping-stored-procedure-results-to-a-custom-entity-in-entity-framework.aspx but I cant get to step 3 since of all the errors when saving on step 2. /M

    Read the article

  • Copy 2 databases without detach in SQL 2005

    - by molgan
    Hello I have a server with live databases, and I have a test-server where I sometimes restore databases from the live one, to get fresh data. But this way I have to set up all the users again, I have about 4 different users with different permissions that need set again. Is there some way to do this a better way without using detach and attach, since I cant take the databases offline on the live-server? Prefered some thing I could run that "re-fills" the tables with fresh data. No need to redo stored procedures and rights. /M

    Read the article

  • Validationsummary with service-layer in asp.net mvc?

    - by molgan
    Hello I have a "service-layer" in my application that handles some logic that uses a "data-layer" that has dataannotations and uses a resource-file with "error-messages" in different languages. How should I implement it in my asp.net mvc application that needs to display some message if a login fails, or if firstname is missing etc? /M

    Read the article

  • Return nullable datetime from scalar, stored procedure

    - by molgan
    Hello I have a function that returns a date from a stored procedure, and it all works great til the value is NULL, how can I fix this so it works with null aswell? public DateTime? GetSomteDate(int SomeID) { DateTime? LimitDate= null; if (_entities.Connection.State == System.Data.ConnectionState.Closed) _entities.Connection.Open(); using (EntityCommand c = new EntityCommand("MyEntities.GetSomeDate", (EntityConnection)this._entities.Connection)) { c.CommandType = System.Data.CommandType.StoredProcedure; EntityParameter paramSomeID = new EntityParameter("SomeID", System.Data.DbType.Int32); paramSomeID.Direction = System.Data.ParameterDirection.Input; paramSomeID.Value = SomeID; c.Parameters.Add(paramSomeID); var x = c.ExecuteScalar(); if (x != null) LimitDate = (DateTime)x; return LimitDate.Value; }; }

    Read the article

  • 3 step validation with dataannotations

    - by molgan
    Hello I'm trying to build a "wizard-like" app that has 3 pages. First one you fill in some requests, then you select time and date, and last step is to fill in your name and address etc. How should the validation be taken care of, since I also need to validate all "3 steps" when pressing submit on the last step. Do I need to have 4 viewmodels there? like step1model, step2model...... and then validateallmodel? And must I use some session-like in between since it "redirect's" to next step if successful? /M

    Read the article

  • Return rows from stored procedure

    - by molgan
    Hello I have this code: public IEnumerable<SomeClass> GetAvalibleThingies(DateTime startDate, DateTime endDate, int categoryID) { if (_entities.Connection.State == System.Data.ConnectionState.Closed) _entities.Connection.Open(); using (EntityCommand c = new EntityCommand("SomeEntities.GetAvalibleThingies", (EntityConnection)this._entities.Connection)) { c.CommandType = System.Data.CommandType.StoredProcedure; EntityParameter paramstartDate = new EntityParameter("startDate", System.Data.DbType.DateTime); paramstartDate.Direction = System.Data.ParameterDirection.Input; paramstartDate.Value = startDate; c.Parameters.Add(paramstartDate); ........ var x = c.ExecuteReader(); return x as IEnumerable<SomeClass>; }; But I can't get it to return a list of SomeClass. What's needed to do here? I use the entity framework 3.5sp1 one /M

    Read the article

  • Linq Having Sum(Quantity) = x?

    - by molgan
    Hello I have a function that returns IQueryable, and I would like to add "HAVING SUM(Quantity) = X" to it, but I get error if I try like this: _rep.GetBookings().ByBookingObjectID(bookingObjectID).Sum(x => x.Quantity == somevariablehere); I cant seem to find functions for it to find by sum /M

    Read the article

  • Viewmodels and Models, howto split them up

    - by molgan
    Hello I'm using asp.net mvc 2 and I'm not sure howto structure the models and viewmodels. In the nerddinner there is only 1 of each. Shall I have only 1 viewmodel of each entity (?) and then have 1 model for each form-modifing viewpage? So that viewmodel contains like all it ever would need, like: PagedFoo FooClass ..., FooClass, Foowithbunnies, FooClassStats... ? /M

    Read the article

  • Include in enity framework 4

    - by molgan
    Hello I've been using enity framework that came with 3.5sp. And now I've redone things for enityframework 4 and asp.net mvc 2. I've come across something (which worked in my previous version and asp.net mvc 1.0). I have this: public IQueryable<Booking> GetBookings() { return from b in _entities.Bookings.Include("BookingObject") select b; } And in my controller I have: return View("Index", new BookingsViewModel { Bookings = _br.GetBookings().ByDay(DateTime.Today) }); And it doesnt seem to include the "BookingObject"-entity, so I can type like <%= Model.Bookings.BookingObject.BookingObjectName %> in my view. What might be missing here? Do I need to turn something on in the diagram for it to include entities or? /M

    Read the article

1