Solved

Filldataset taking long time in vb.net

Posted on 2014-01-05
4
203 Views
Last Modified: 2014-02-28
I have the following sp Get_Patient

  Declare @Ctdate varchar = dbo.fnSqlDateFormat_String(Getdate())

 Select Top 100 A.Patientno,A.createdate,Titleid,B.Value Title,Patientname,  
   (Case when dd = 0 and mm = 0 and Yr > 0 then (Cast(yr as varchar) + ' Yr(s)')
        when dd > 0 and mm = 0 and yr = 0 then (CAST(dd as varchar) + ' Day(s)')
        When dd = 0 and mm > 0 and yr = 0 then (CAST(mm as varchar) + ' Month(s)')
        Else '' End) Age,Sex,Phone1,Mobile1,email,A.LoginName,A.Concurrencyid,PAddress,
        (case when (DOB is null) Or (DOB = '') then null else dbo.fnString_SqlDateFormat(DOB)End)DOB,
        dd,mm,yr,A.rowid
   from Master_Patient A  
   Left join
   ( Select rowid Id , fieldValue Value from Master_Common  where field = 'Title'
   )B on A.Titleid = B.Id   --where PatientName like '%' + @Searchstring + '%'  and blndisable = 0
   Where A.Createdate  = @Ctdate  

When this sp is executed using filldataset , it executes very fast. but when  i use the following way   .. Where  A.Createdate  =   dbo.fnSqlDateFormat_String(Getdate())
the filldataset is taking very long time to fill the dataset.

But in qry analyzer, both qry run very fast.

Can some expert tell what may be the reason
0
Comment
Question by:venkataramanaiahsr
4 Comments
 
LVL 40

Expert Comment

by:Jacques Bourgeois (James Burger)
Comment Utility
Query Analyzer enables you to test and possibly increase the performance of a specific query. But it does not always show properly the way things are handled by the client.

But Dataset.Fill intervenes in some way. For instance you can pass parameters to a stored procedure through an EXEC call or through SqlParameter objects. The second one takes more code but is usually faster than calling EXEC, even if under the hood you are using the same stored procedure.

This probably comes into consideration in your tests.
0
 

Author Comment

by:venkataramanaiahsr
Comment Utility
execution time of   filldataset of storedprocedure  in the following two cases is different

 1.   Declare @Ctdate varchar = dbo.fnSqlDateFormat_String(Getdate())
 
   .   ...  Where A.Createdate  = @Ctdate       ------Fast
 
 2.   .. Where  Createdate  =   dbo.fnSqlDateFormat_String(Getdate())   -- Slow

Any specific reason ?
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
Comment Utility
Sometimes you can see gains if you do some of the work on the code side, instead of the database side.  Query analysis would let you know what is taking a long time.

Another optimization is to turn off constraints when filling a DataSet.

How to: Turn Off Constraints While Filling a Dataset
http://msdn.microsoft.com/en-us/library/s3bxwk8b.aspx
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now