项“attachdbfilename”的值无效。

来源:百度知道 编辑:UC知道 时间:2024/06/02 02:43:48
我是用VS2005+SQL2005编写的,使用的是C#语言
帮我看看有什么错误!
谢谢!
说明: 执行当前 Web 请求期间,出现未处理的异常。
我在web.config中数据库链接代码:

<appSettings>
<add key="ConnString" value="Data Source=z20223.\SQLEXPRESS;User ID=sa;Password='';Initial Catalog=WEBCOURSE;"/>

<add key="ConnString" value="Data Source=z20223.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\WebCourse_Data.MDF;Integrated Security=True;User Instance=True;" />

源错误是:

行 65: {
行 66: string sqlString = "select * from DeptInfo where IsDeleted=0";
行 67: return SqlHelper.ExecuteDataset(SqlString, CommandType.Text, sqlString);
行 68: }
行 69: }
我用的是asp.net编写的动态网

<connectionStrings>
<add name="HConnString" connectionString="Data Source=z20223.\SQLEXPRESS;Initial Catalog=|DataDirectory|\WebCourse_Data.MDF;User ID=用户名;Password=密码" providerName="System.Data.SqlClient" />
</connectionStrings>
-------
连接字符串的问题

首先这个提示的意思就是该列名attachdbfilename不存在

select * from DeptInfo where IsDeleted=0
返回的数据集是什么?
仔细检查一下DeptInfo 表,有attachdbfilename字段吗?