Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
MaverickUK
Yak Posting Veteran
89 Posts |
Posted - 2003-05-13 : 08:55:36
|
| This is more a C# issue than SQL Server, but seeing as alot of people round this forum seem to be both back-end & front-end developers, I thought it was worth bringing up.For most my major projects now I'm using MS SQL 2000 & ASP.NET C# webpages. Most my work involves database access, so I've tried to come up with a method of making database transactions fast to program but also good for performance.I wanted to ask everyones thoughts on this, to see if you believe such an approach is a good idea. Bearing in mind that it'll always to faster to run a trailer made database transaction, but this method makes writing database access's in C# much easier.The system is basically based around a set of methods in a class which are called to run the database query. Plus an ArrayList which holds the parameters to feed in.A Struct is stored in the ArrayList for every parameter, which holds the param name, datatype, value, etc..Once all the parameters have been added, an execuate method is called, which then returns a DataTable will any data returned.So basically a sample database call might look like this DBParamClear(); DBParamAdd( "@RecordID", SqlDbType.Int, iRecordID, 0 ); DBParamAdd( "@IsLive", SqlDbType.Int, iLiveStatus, 0 ); DBParamAdd( "@LiveDetails", SqlDbType.VarChar, sLiveDetails, 5000 ); DataSet dsExample = DBRunProcedureReturn( DB_SPSETRECORDLIVE, true ); Of course throwing around DataSets and ArrayLists is never going to be as fast as hand coding it all. But given the time savings this approach has given me, I'm not in any hurry to find a slower way of doing things ;)So what are your thoughts on this approach? |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-05-13 : 10:02:23
|
Not my forte'...but when you say:quote: set of methods in a class which are called to run the database query
Do you mean you're passing a query to the server?If that's the case, I would say that stored procedures are the way to go, since they are compiled and will have an execution plan.Just a thought (I have so very few...)Brett8-) |
 |
|
|
macka
Posting Yak Master
162 Posts |
Posted - 2003-05-13 : 10:03:03
|
| There's a number of good code generators out there which save you writing alot of tedious Data-Access code. I use LLBLGen ([url]http://www.llblgen.com/[/url]). Full source code is available, so you can modify it to suit your own requirements.Obviously, there are instances when you will need to optimize this code and actually hand-code the data access - the good bit is, these instances tend to be the interesting elements within a project.macka.--There are only 10 types of people in the world - Those who understand binary, and those who don't. |
 |
|
|
|
|
|
|
|