RE: execute SP on the dataSet

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Suresh (anonymous_at_discussions.microsoft.com)
Date: 03/24/04


Date: Wed, 24 Mar 2004 09:26:06 -0800


>So is it possible to execute stored procedure on my DataSet?

No. But you can select certain records from a DataTable specifying some filter using the DataTable.Select(.....) method.
You can't do joins in the dataset either.

Click on the link for more details and sample.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatatableclassselecttopic.asp

HTH,
Suresh.

     
     ----- simon wrote: -----
     
     Hi,
     I have for example 3 tables in my database which is on SQL server.
     
     Than I have Stored procedure, which returns the data from that tables
     depends on the input date.
     
     Every time when user in my application change the data from calendar, this
     procedure on sql server is called
     and returns one table and the dataSet (in fact dataTable) is recreated from
     the database and dataGrid is rebind to that table in dataSet.
     
     Because my tables in database are updated only once a day I thought:
     
     What If I copy 3 tables from the database into the dataSet and
     than when user change the date, execute this procedure on the dataSet
     (which is on web server) instead of on the database in my sql server which
     is on
     the other machine.So is it possible to execute stored procedure on my
     DataSet?
     
     Or is there some better solution?
     
     The sintax of SP is very complicated, I'll put here just for information:
     
     CREATE PROCEDURE c_returnTimeSlots
     @mediaId as integer,
     @datumStart as datetime
     AS
     DECLARE @week_start DATETIME
     
     SET @week_start =
      DATEADD(D,FLOOR(DATEDIFF(D,'19000101',@datumStart)/7)*7,'19000101')
     
     declare @presezenCas int
     set @presezenCas=(SELECT cast(set_value as int) FROM cpoSettings WHERE
     set_id=1 AND set_medID=@mediaId)
     
     --advFree pogledam, èe je ¹e kaj prostora za reklamo in sicer, èe obstaja
     reklama, ki je posegla v prese¾en èas
     
     select T1.*,advFree=case when exists(SELECT * FROM cpoTimeAdv WHERE
     ts_id=T1.ts_id AND adv_end>=(dateadd(ss,@presezenCas,T1.endDateHour)))
     then 0 else 1 end
     FROM
     (select t.ts_id,datepart(HH,t.ts_startDate)as
     startHour,datepart(HH,t.ts_endDate)as endHour,
     datepart(mi,t.ts_endDate)as endMinute,datepart(ss,t.ts_endDate)as endSecond,
     LEFT(DATENAME(DW,t.ts_startDate),3) as
     startDay,LEFT(DATENAME(DW,t.ts_endDate),3) as endDay,
     CONVERT(VARCHAR,t.ts_startDate,108) as
     TimeStart,CONVERT(VARCHAR,t.ts_endDate,108) as
     TimeEnd,a.adv_id,a.cnt_id,a.adv_name,
     datepart(HH,ta.adv_Start)as startAdv,datepart(HH,ta.adv_End)as
     endAdv,t.ts_startDate as startDateHour,t.ts_endDate as endDateHour,
     CONVERT(VARCHAR,t.ts_startDate,112) as startDate,ta.adv_Start as
     advStart,ta.adv_End as advEnd
     from cpoTimeSlot t left outer JOIN cpoTimeAdv ta ON t.ts_ID=ta.ts_id
     LEFT JOIN cpoAdvertisments a ON ta.adv_id=a.adv_id
     WHERE ts_medId=@mediaId AND
     (ts_startDate BETWEEN @week_start AND DATEADD(D,7,@week_start)
     OR ts_endDate BETWEEN @week_start AND DATEADD(D,7,@week_start))
     ) as T1
     ORDER BY T1.startDateHour,T1.advStart
     GO
     
     Thank you for your answer,
     Simon
     
     
     
     



Relevant Pages

  • Re: Alternative to Dynamic SQL?
    ... We have a single user per database. ... You use SQL Server logins for security as opposed to Integrated Security? ... DBA....and Tony was the developer and Tony wanted a pagination query, ... You can use a stored procedure to paginate database-side as well, ...
    (microsoft.public.sqlserver.programming)
  • Re: using sp_ as a naming convention for stored procedures
    ... System stored procedures are created and stored in the master ... database and have the sp_ prefix. ... from any database without having to qualify the stored procedure name fully ... SQL Server always looks for a stored procedure ...
    (microsoft.public.sqlserver.programming)
  • Re: Debug stored procedures with VB6
    ... > I can't see in the sql server analyser a tool to debug a stored procedure. ... > "Val Mazur" a écrit dans le message de ... >>>>> My database is installed locally. ...
    (microsoft.public.vb.database.ado)
  • RE: ASP.NET/Linked Server connection problem
    ... Destroy security and open the database for hackers by reducing security ... Wrap your work in a stored procedure that your connecting user account ... Create a custom ETL application to move the data. ... > I am trying to create/use a SQL Server Linked Server definition from ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Facing the same problem
    ... My stored procedure is being activated from a Service Broker ... remote server is denied because the current security context is not ... The linked server is a SQL server, but not one where I have any ... ALTER DATABASE db SET TRUSTWORTHY ...
    (microsoft.public.sqlserver.security)