Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
NvarChar instead of varchar
Message
From
18/11/2003 18:23:36
Fabian Valencia
Calamos Asset Managment Inc.
Naperville, Illinois, United States
 
 
To
All
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
NvarChar instead of varchar
Miscellaneous
Thread ID:
00851229
Message ID:
00851229
Views:
50
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
Reply
Map
View

Click here to load this message in the networking platform