在Sql Server2008中出错 [英] To error in Sql Server2008

查看:83
本文介绍了在Sql Server2008中出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了SQL Server 2008 R2&使用用户名=``sa''&配置服务器混合模式身份验证密码=``pw''
并且我的附件.mdf文件位于D:\ TransparentTest \ ForTest中,并且服务正在运行.

现在,我通过编码连接server2008附件.mdf文件,但未连接.错误消息已显示(无法打开物理文件" D:\ TransparentTest \ ForTest \ sd.mdf.操作系统错误32:" 32(该进程无法访问该文件,因为该文件正在被另一个进程使用.)".
尝试为文件D:\ TransparentTest \ ForTest \ sd.mdf附加自动命名的数据库失败.存在具有相同名称的数据库,或者无法打开指定的文件,或者它位于UNC共享上.'')

我的代码如下:->
--------------------

I have install the SQL server 2008 R2 & configure the server Mixed mode authentication with username = ''sa'' & password = ''pw''
and my attachment .mdf file is located in D:\TransparentTest\ForTest and service is running.

Now i connect the server2008 attachment .mdf file through coding but not connect. Error msg shown(''Unable to open the physical file "D:\TransparentTest\ForTest\sd.mdf". Operating system error 32: "32(The process cannot access the file because it is being used by another process.)".
An attempt to attach an auto-named database for file D:\TransparentTest\ForTest\sd.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.'')

My code is below :->
--------------------

SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=MachineName\MSSQLSERVER2008; AttachDbFilename=D:\TransparentTest\ForTest\sd.mdf;User Id=sa;Password=pw";
con.Open();



上面的代码在Sql Server2005中可以很好地工作,但是在Sql Server2008中不能工作.
我该如何解决以上问题??
请帮助我正确的指导...



Above code is fine working in Sql Server2005, but not working in Sql Server2008.
How will i solve above problem???
Please help me proper instruction......

推荐答案

在此处查看: http://connectionstrings.com/sql-server-2008 [ ^ ]


这篇关于在Sql Server2008中出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆