Thursday, October 09, 2008

Service-Based Database

If you still like those good old days of having your database file shipped with your application instead of relying on a SQL server be installed at the client machine, then you may want to add a SQL Server Express Database to your application. It is still possible to add a file based database to your application which Microsoft calls Service-Based Database [I don't think anyone knows why is it called this] but anyway, you can add it and that's what matters.

You can add the database by right click your project and select add item, then select data from the categories box and then select Service-Based Database as per the screen shot below.


However, if you do so, you may be challenged by the error message

Failed to generate a user instance of SQL Server due to a failure in
starting the process for the user instance. The connection will be
closed.

To solve this problem you really wanna make sure you have an administrator user on your machine. it seems you must start your visual studio as an administrator rather than any other user to be able to add this database to your solution.

To do so and start your visual studio as an administrator, right click your visual studio short cut and select run as as per the screen shot below












When you do so, you will get another dialog box that will ask you to type the name of the administrator user and the password. type the administrator user account and password.



Now don't tell me I am already an administrator on my machine!! doesn't work. the user name has actually to be called "Administrator" if you're an administrator on your machine in the administrators group that doesn't help. you ask why? I don't know.

If your machine does not have an administrator user called Administrator, then create that user and add it to the administrators group so that you can type that name in the dialog above.

Some people reported that this solution worked with them


HTH

No comments: