Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
NvarChar instead of varchar
Message
De
18/11/2003 18:23:36
Fabian Valencia
Calamos Asset Managment Inc.
Naperville, Illinois, États-Unis
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
NvarChar instead of varchar
Divers
Thread ID:
00851229
Message ID:
00851229
Vues:
48
I'm creating a business objects that returns a dataset with a parameterized query, the code works but it runs 10 times slower than what it needs to be, this is the code:

mmDataAccessBase dao = this.GetDataAccessObject();

IDbDataParameter param1 = dao.CreateParameter("@cCamsec", cCamsec);
IDbDataParameter param2 = dao.CreateParameter("@dBegDate", dBegDate);
IDbDataParameter param3 = dao.CreateParameter("@dEndDate", dEndDate);

// Get prices for date range
mmDataSet ds = (mmDataSet)this.GetDataSet(
"SELECT Camsec, Price, Date FROM Price where camsec = @cCamsec and " +
" bestpx = 1 and Date BETWEEN @dBegDate and @dEndDate", param1, param2, param3);

return ds;


As you can see this is pretty simple, the problem starts when this takes way too long, by looking at the SQL profiler, I noticed that cCamsec is been turned into a nvarchar type when sent to SQL, if I take the same query that is been executed and change it to varchar instead, it takes no time at all.

Any help is appretiated.

Thanks
Fabian
Répondre
Fil
Voir

Click here to load this message in the networking platform