views:

235

answers:

2

I have a file that contains lots of insert statements to populate my compact edition database with test data. I have been running the file from Sql Server Management Studio each time I run a unit test (I'm using NUnit). Now I want to automate the running of database scripts for each test. I'm trying to use osql as described in this article: Unit testing the data layer The problem is that I don't know how to connect to an sdf file using osql. I have 2 problems, First I don't have a User Id for the database, only a password. I've tried this at a command line prompt:

osql -P manager -S 192.168.1.117 -i "C:\...\InsertTestData.sqlce" -D "C:\...\Test.sdf"
Error: No user selected. Try with -U or -E switches

Second, I don't know how to specify the database. I've tried this:

osql -P manager -S 192.168.1.117 -i "C:\...\InsertTestData.sqlce" -D "C:\...\Test.sdf" -U sa
[ODBC Driver Manager] Data source name not found and no default driver
specified

So can I add a user id to Sql CE Server? How do I specify the database/filepath? Or is there another way I can connect?

+1  A: 

Check out http://social.msdn.microsoft.com/Forums/en-CA/sqlce/thread/9540dbe4-e0d9-4381-a475-42691d641570

It would seem that osql and sqlcmd do not work for compact editions.

Thies
Thank-you Thies. I particularly like the look of the link to Steve Laskers weblog http://blogs.msdn.com/stevelasker/archive/2007/03/31/creating-your-sql-server-compact-edition-database-and-schema-in-code.aspx
Colin
A: 

You can use sqlcecmd: http://sqlcecmd.codeplex.com

ErikEJ