06 September, 2009

Deploying a SQL Database to a Remote Host by using ASP.NET 2.0 callbacks

Though The Database Publishing Wizard can provide separate scripts for diferent objects and current PCs are pretty powerful, the copy / paste approach is unlikely to handle more than tenths of megabytes of script. But for many developers it would be okay in many cases. In next versions I hope I'll overcome the limitation.

You are uploading an .aspx page to a remote host and pointing Internet Explore to the page; then the application creates the database.

The difference to http://www.codeplex.com/sqlhost is that you need no uploading a SQL script to the host; you are supplying the .aspx page with the SQL script through the ASP.NET 2.0 Callbacks mechanism.

The drawback is that you can’t paste big SQL scripts into the text box; the advantage is that you can track the process of Script execution. Also when you upload a content of a table, you may not repeat the lengthy

INSERT [dbo].[SomeLengthyName] ([ApplicationGuidId], [UserGuidId], [SomeOtherGuidId], [YetAnotherGuidId], [index], SomeIntValue VALUES ('497705fc-6bb3-4f9d-90d8-d1a067c47348', [OtherGuid], [OtherGuid], [OtherGuid], [OtherGuid], 33, 7)

It’s a bit overkill to send two hundred bytes to just populate a field with, say number one 7. The command could be kind of “repeat previous” – two bytes plus two bytes - number of chars; this gives 4 bytes instead of 200 and plus the rest of a string. But that’s yet to be implemented.

So, have a look at a screen shot in a previous this blog’s message and if you decided to give a try to the idea, try it with you local database first:
- create some ASP.NET 2.0 project on your PC using VS.NET 2.0.
- create SQL database; I named it “DB”;
- edit connectionString in your “web.config” file to point to the database;
- copy Default.aspx code from one of the previous messages of this blog; replace your Default.aspx code with it;
- copy Default.aspx.vb code-behind from one of the previous messages of this blog; replace your Default.aspx.vb code-behind with it;
- launch the application;
- get The Database Publishing Wizard’s .sql file to some text editor, copy it to clipboard;
- paste the SQL script into the application’s textbox;
- click “Process” button.

The rest you can discover on you own, examining the controls and the code. Good Luck.

http://aspdotnetway.blogspot.com/

No comments: