Copying database schema and data using C sharp

To copy the database structure and data content from one database to another, you can use C# codes as follows: class Program { static void Main(string[] args) { Console.WriteLine("Attempting connection to database..."); // Connect to Server ServerConnection _con = new ServerConnection(); Server server = new Server("VM0019\\SQLEXPRESS"); // Get the Database to Transfer Database db = server.Databases["gices"]; // Setup transfer // I want to copy all objects // both Data and Schema Transfer t = new Transfer(db); t.CopyAllObjects = true; t.DropDestinationObjectsFirst = true; t.CopySchema = true; t.CopyData = true; t.DestinationServer = "VM0019\\SQLEXPRESS"; t.DestinationDatabase = "testcopy"; t.Options.IncludeIfNotExists = true; // Transfer Schema and Data t.TransferData(); // Kill It server = null; Console.WriteLine("Closing database connection now...Program terminated"); } } You need to ...

Written by avinashsing on February 21st, 2008 # Filed under Programming # No Comment #

Mass drop of Stored Procedures in SQL Server

Sometimes you need to mass drop stored procedures in a database. Well i needed a convenient way to do delete all stored procs starting with the word 'asp' on my local DB. The following codes did the job really well: select Name + ',' from sys.objects where Type = 'P' and name like '%asp%' This will return you a list of sprocs separated by a comma which you can copy and paste into the next code, as follows: drop procedure aspnet_Setup_RestorePermissions, aspnet_Setup_RemoveAllRoleMembers, aspnet_WebEvent_LogEvent, aspnet_Personalization_GetApplicationId, aspnet_Users_DeleteUser, aspnet_AnyDataInTables, aspnet_Applications_CreateApplication, aspnet_Membership_GetUserByName, aspnet_Membership_UpdateUserInfo So instead of dropping each stored procedure manually, you can drop many ...

Written by avinashsing on February 21st, 2008 # Filed under Programming # No Comment #

Introduction to Windows Application Programming

I'm not too much into Windows Application Programming because i tend to concentrate on building applications for the Web. However the other day i wanted to do a little application for Windows and i got stuck a bit. I usually write a small app with just 1 form but when your app contains more than one Form, then you really need to think how you are going to design it. First things first - you can have a main Form which loads subsequent forms through an MDIForm interface. This means that ...

Written by avinashsing on February 19th, 2008 # Filed under Programming # No Comment #

Submitting form data to a webpage

There are a number of reasons why you would want to send form data to a webpage but i was just trying to automate the process of logging into a website. The website itself presents a form where you need to enter a valid username and password. The following links will help you to build a small application in C# to do just that: Strikefish Sys-Con Note that the method to send post data to an ASP.NET is quite different because you need to have a consistent viewstate information. Also, if you are trying ...

Written by avinashsing on February 12th, 2008 # Filed under Programming # 2 Comments #

C# coding standards

The following documents show the best practice for coding in ASP.NET and C#. There's also a Web Deployment document to show how to deploy projects without overwrite the web.config file and deleting test pages and SubVersion files. dotnetcodingstandards.doc web-deployment.doc How to set the default page for a website in the MSI? After adding a web setup project to the solution, you will need to right click on the setup project and choose 'File System' (File System Editor). If you then right click on the 'Web Application Project' and view the propertie, you will be ...

Written by avinashsing on February 11th, 2008 # Filed under Programming # No Comment #

Stored procedures and database guidelines

The following documents show the best practice for designing database schemas and stored procedures: sqldatabasedesignguidelines.doc sqlimplementationprocedures.doc sqlstoredprocedureaddendum.doc sqlstoredprocedureguidelines.doc

Written by avinashsing on February 11th, 2008 # Filed under Programming # No Comment #

Moved to wordpress

Being a Microsoft guy, i wanted to have a blogging platform on windows. So i initially wrote a small application which would allow me to write simple stuffs. As i started using the app though, i found that i needed more functionality built into it but since i didn't have any time to do it myself, i deciced to search for a blogging engine that would have the facilities i was looking for and two, be able to run on a windows platform. I thought about WordPress but because it's ...

Written by avinashsing on February 10th, 2008 # Filed under Miscellaneous # One Comment #