Generic method to run sql from files


i have program should work against multiple dbs. dbs don't have capability of sp. because of want store sql commands inside text files. now, want create generic method read text files , run them want method stupid possible because want reduce compilation code since program sent end user. don't want program decide params send since change cause compilation. initial solution put tokens inside text files match names of properties of object i'll send generic method , using reflection i'll replace token exists in specific file. think solution, , have other ideas?

tsahi bar

generally db access should done via self-written abstraction layer. wheter db supports stored procedures or not irrelevant then. write 1 implementation per dbms, based on same interface or abstract base class. actuall programm uses defined in said interface/base class, wich of dbms adapters instantiated irreleavant.
makes swapping out 1 dbms class other single line change. here example of design:
http://www.codeproject.com/articles/43438/connect-c-to-mysql

even taking user input , connacting query without sanitizing bad idea:

http://en.wikipedia.org/wiki/sql_injection

http://xkcd.com/327/

ideally use sql-paramters, type safe , injection proof (http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlparameter.aspx).

taking whole query string source asking write down "drop database" line. , db-code should never allow (and before think it, jsut filtering keywords nto going work either. if writese commet "--this should not drop database"?)


let's talk mvvm: http://social.msdn.microsoft.com/forums/en-us/wpf/thread/b1a8bf14-4acd-4d77-9df8-bdb95b02dbe2 please mark post helpfull , answers respectively.



Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'