开发者

Uploading A SQL Server Script?

My over all goal is to upload a very simple ASP.NET web site created in C# and using a SQLEXPRESS DB to a hosting provider via FTP.

I understand that I can get all of my ASPX, .CS, master pages and image files with no problem. Problem I am having and reason I am here is because I cant simply pop my MDF file into my hosting provider's (Verio Hosting) site.

On the web I ran across a post by Scott Gu. In his post he wrote about converting a MDF into a .SQL file which you can execute from a web site. See below....

If your hoster has no usable HTML web admin tool for allowing you to easily manage your SQL database, then you can also just write a simple ASP.NET page that you FTP (along with your .SQL file) to your web-site and then hit to read the .SQL file on the server in as text, and then pass it as a string to ADO.NET to execute. This will give you the same result as the query analyzer above - and fully create your database for you.

I created the .SQL file and I am capable of popping this .SQL file into my website. My question to you guys is how do I create that simple ASP.NET page that I can then hit to read, and then do everything else that Scott mentioned in the passage above????

EDIT: I found out that that I can just re-create my DB by remotely logging in to my hosting providers SQL 开发者_JAVA技巧server via SQL Mgt Studio. I dont want to do this for two reasons 1.) It feels cheap knowing that there is a much cooler way to do this, and 2.) I dont know how to re-create the ASPNETDB.MDF that I use for my user database that ASP.NET created for me.


My question to you guys is how do I create that simple ASP.NET page that I can then hit to read, and then do everything else that Scott mentioned in the passage above????

Which part of the process don't you understand?

It's just a regular *.aspx web form; you do all of the work in the code behind.

BTW, when sending commands to SQL Server via ADO.NET, keep in mind that ADO.NET doesn't understand "GO" statements; if your script contains them, you will either have to parse them out and submit batches accordingly, or arrange to invoke a command-line tool like sqlcmd from your page, if your hosting provider allows it.


You simply need to have the ASP page read in the .SQL file, which is a series of SQL queries to be executed. Loop though the contents of the file, running each query in turn. The queries will create the db schema, insert the data, etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜