views:

59

answers:

2

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 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.

+1  A: 

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.

Peter Loron
Thanks for the reply Peter, hope this comment doesn't upset anyone... But "How do I do all of what Scott and Peter have posted"? I'm just a beginner, creating webpages on my local machine has been a snap thanks to the magic of asp.net. Does anyone have any examples as to how to do what Peter and Scott are saying? One of the databases that I am converting is the user/roles .net database ASPNETDB.MDF. After converting it to a .SQL file and opening it up in a text editor, I was like OMG WTF. :)
NoDinero
+1  A: 

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.

RickNZ
Parts I do get is creating an aspx page. I can do that blindfolded :).The part I dont get is (and this is my greatest weakness) is doing the code behind. ADO.NET is still a mystery to me. But so were Masterpages when I first started, I shyed away from them thinking that they were super crazy mysterious, but now I cant live without them. What I am NOT asking for, is the answer in a silver platter, but rather an example of what I should be doing, a link to an online article maybe. Like I said I have the foggiest idea of what I need to do with this SQL script.
NoDinero
Rick, I understand now (somewhat) what you and Peter were saying. I found a quick solution however, using SQL Manager Studio. I can remote into my SQL database located on my hosting providers sql server, run my sql scripts, and generate my tables. BADA-BING-BADA-BOOM! Talk about Auto-magical!!!Still, reading up on ADO.NET helped me understand (somewhat) how my applications really communicate with my database. I really don't want to be a point-and-click developer all my life. Thanks all
NoDinero