General information
Category:
The Mere Mortals .NET Framework
Title:
NvarChar instead of varchar
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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only