Create Database By XML in C# application

  • Hi,

    I wrote a c# application which uses sql server 2005. I finished it and now i want to run the

    application with the same DataBase on another computer.

    Is there any way to create the DataBase automaticlly on the destination computer befrore i run the application on it? perhaps by running XML file on the computer?

     

    Thanks In Advance

  • What about using the script database function in sql server management studio? Right click the DB, script database as, create

  • Could you please describe in more detailed way what I should do?

    After I create this script file, I just need to run it on the destination computer?

    Thanks

  • hi,

    You just run the sql script in Application_Beginrequest event in Global.asax to create database for you.

  • You can also use the ServerConnection class in SMO to execute arbitrary scripts from code (even if they have GO keywords in them).

    Check out the ServerConnection.ExecuteNonQuery() and similar methods. 

    ServerConnection class is described here: http://msdn2.microsoft.com/en-us/library/microsoft.sqlserver.management.common.serverconnection.aspx

    ---------------------------------------
    elsasoft.org

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply