Printable Version of Topic

Click here to view this topic in its original format

IBB Forum _ MS SQL Server _ How To: copy a database and create a System-DSN

Posted by: CB 25. Jun 2012, 08:16

There a several ways to migrate a database from one system to another. I show you one I allways use when it comes to the situation that a customer needs to set up a new system and migrate the test-rig-software and all the data to that system.

First of all you need a Microsoft SQL Server (2005 Express) on that machine. With the SQL Server comes the Microsoft SQL Server Management Studio (Express) which is the software you need to control and configure your SQL Server.

Step 1: locate and copy the database files on the old system
if you know where your files are, you can directly copy them to your new machine. If you don't the SQL Server Management Stuido can help. Open the SQL Server Management Studio and select your database on the left side:

right click and select "properties" to get the properties dialog:

select "files", scroll to the right and you can see the folder where your files are saved and the filenames. There must be 2 files: databasename.MDF and the databasename_suffix.LDF, which is the log-file. You need them both if you don't want to confuse your SQL-Server. Grab these 2 files and copy it to your new machine.

Open the SQL Server Management Studio (Express) on your new machine, right-click on the "databases" entry in the tree-menu and select "attach":

Click on "add" in the "attatch database Dialog" and select the files you have copies recently. Now the database should appear in the tree menu on the left side.

Part 2: create a system DSN to get this database running with LabVIEW
Because LabVIEW is still a 32-bit application you have to create a 32-bit System-DSN to get your application run with your database. This part comes a little bit tricky ...

Start the 32-Bit ODBC-Manamger: C:\Windows\SysWOW64\odbcad32.exe by typing this command into a shell or eg. by creating a shortcut to this executable on your desktop (right-click on your desktop, select new and then "shortcut") and doubleclicking it. I prefer the "shortcut method" because I had some issues with the "shell-method" (got a 64-bit DSN anyway ... ???) which is described in the following screenshots:

doubleclick on this icon:

that will open the 32-bit ODBC Manager. Select "System-DSN" (if you want this data source to be availiable for all users) and select "add":

Step 1: select a driver (the SQL-Server driver is in most cases at the bottom of the list ...)

Step 2: chosse a name for your DSN and select the server. Hint: it's a good practice to add "_32" as suffix to 32-Bit datasources, because that helps you to identify if that is a 32 Bit or a 64 Bit DSN later

Step 3: select "Windows authentification" and click on "proceed"

Step 4: select your Database an click on continue

Step 5: click on "finish"

Step 6: this dialog shows you a summary of the DSN settings. Click on "test data source" to validate your data source

Step 7: this dialog show you that your DSN is set up properly

If you can read something with "success" then everything is all right and you can use this DSN with your LabVIEW application!

Good Luck!

Powered by Invision Power Board (
© Invision Power Services (