Initialization in web services
-
hello, My Web Service accesses to a MS SQL database to store and retrieve data from it. but to store data, first I must to create programatacally the database and the tables. My question is what is the best way to do this? where is the best place to put the code which do this? In the beginning of each Web method (if the database and the tables do not exist, of course) or there is a common place to create or to initialize data, structures, systems, connections, etc.? thanks in advance.
-
hello, My Web Service accesses to a MS SQL database to store and retrieve data from it. but to store data, first I must to create programatacally the database and the tables. My question is what is the best way to do this? where is the best place to put the code which do this? In the beginning of each Web method (if the database and the tables do not exist, of course) or there is a common place to create or to initialize data, structures, systems, connections, etc.? thanks in advance.
Actually, the best way to do it is to run the SQL script that creates everything either ahead of time, or when the Web Service is installed. Checking for the existance of the database on every call is very unecessary and just wastes time and resources doing the checks for something will only be done once. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
hello, My Web Service accesses to a MS SQL database to store and retrieve data from it. but to store data, first I must to create programatacally the database and the tables. My question is what is the best way to do this? where is the best place to put the code which do this? In the beginning of each Web method (if the database and the tables do not exist, of course) or there is a common place to create or to initialize data, structures, systems, connections, etc.? thanks in advance.
pelos wrote: first I must to create programatacally the database and the tables. My question is what is the best way to do this? Don't forget to add data. Aside from what Dave said I think you may be confusing two aspects of the software development lifecycle. You can manually type the DDL to create your database, tables and insert data into or you can use the visual tools that popular RDBMS provide. The purpose of web services is to allow a tranparent transport protocol regardless of operating system for data flow. Does that make sense? - Nick Parker
My Blog | My Articles