在 ASP.NET 服务器上查找 .sdf 文件时出错
我已经完成了一个网络项目(使用 C# + SQL CE + ASP.NET),其中很少对 .sdf 文件进行操作,结果通过 ASP.net 页面显示。当我开始工作时,我对连接字符串的路径进行了硬编码并在我的系统中工作。现在我希望这个数据库位于我的服务器页面内。
我如何获取工作目录(本地主机) 我可以把它联系起来 字符串?
我尝试使用
System.Environment.CommandLine 但它向我抛出一个错误
"Format of the initialization string does not conform to specification starting at index 98." The outcome of System.Environment.CommandLine is
Data Source= "C:\Program Files\Common Files\Microsoft Shared\DevServer\9.0\WebDev.WebServer.EXE" /port:1438 /path:"C:\Documents and Settings\xxx\Desktop\Project\yyy\Deploy\EMSWEB\Back010\WEB\WEB" /vpath:"/WEB"/tEST.sdf;Persist Security Info=True;
任何想法???
I have done a web project ( using C# + SQL CE + ASP.NET )where it does few manupulation with .sdf file and results are displaye via ASP.net page . While i started working I hardcoded the path of the connection string and worked in my system . Now I want this database to be residing inside my server page.
How do i get the working directory( localhost) so
that i can put that in connection
string ?
I tried using
System.Environment.CommandLine but it throws me a error saying
"Format of the initialization string does not conform to specification starting at index 98." The outcome of System.Environment.CommandLine is
Data Source= "C:\Program Files\Common Files\Microsoft Shared\DevServer\9.0\WebDev.WebServer.EXE" /port:1438 /path:"C:\Documents and Settings\xxx\Desktop\Project\yyy\Deploy\EMSWEB\Back010\WEB\WEB" /vpath:"/WEB"/tEST.sdf;Persist Security Info=True;
Any idea ???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看看 http://www.connectionstrings.com/sql-server-2005-ce
Have a look at http://www.connectionstrings.com/sql-server-2005-ce
只是一个快速建议:切勿将其放入真实环境中。 SQL Server CE 不能用作 Web 应用程序的数据库。它在并发访问时表现不佳。
正如 @KBoek 所说,connectionstrings.com 应该涵盖您的任何连接字符串问题。无论是Desktop还是Server,只需正确指定数据库路径即可。我建议您将 .sdf 文件保留在与其他文件相同的目录中
,并使用类似的内容
Just a quick advise: Never put this in to a real environment. SQL Server CE is NOT to be used as a database to a web application. It does not perform well with concurrent access.
And as @KBoek has said, connectionstrings.com should cover any of your connection string problems. Whether it is Desktop or Server, it is only a matter of specifying the path correctly to the database. I suggest you keep the .sdf file in the same directory as your other files
and use something like
指向某个目录使其工作
我最终使用where as
,如下所示。
I finally made it work using
where as
Points to some directory like this below.