Retreiving one time configuration parameters from multiple tables is a norm in todays database based applications and by following this technique reducing the roundtrips to an acceptable level could be achieved.
string conString = "your_connection_string" ;string sqlString = "Select * from Suppliers; Select * from Vendors" ;OracleDataAdapter adp = new OracleDataAdapter(sqlString, conString) ;DataSet dst = new DataSet() ;adp.Fill(dst) ;
Look at the query variable it contains more then a single table separated by commas, this is a powerful feature through which you could query more then one table in one database call, imagine how you are reducing the roundtrips to a normal level, when your application have thousand of database hits, life become eaier and also fun.
But when you execute this ADO.NET will replace the orignal table names with something like Table1, Table2 and so on, so work accordingly simply use DataAdapter's TableMapping method to change the name back to their orignal names.
adp.TableMapping.Add("Table1", "Suppliers") ;adp.TableMapping.Add("Table2", "Vendors") ;
Notice we are running through Table1..2 and its because ADO.NET name them by starting from 1 to number of tables requested during DataAdapter call.
Try out and let me know how you feel the difference.
Cheers,
Remember Me
Powered by: newtelligence dasBlog 1.8.5223.0
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.
© Copyright 2009, Danish Sami, et.al.
User Group Lead