Can I use osql with Sql server Compact Edition

时间秒杀一切 提交于 2019-12-12 14:34:50

问题


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:


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.




回答2:


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



来源:https://stackoverflow.com/questions/2132421/can-i-use-osql-with-sql-server-compact-edition

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!