在web.config里面如下添加如下配置
<appSettings>
<add key="NWind"
value="server=127.0.0.1;user id=sa;password=qiujun;database=Northwind"/>
</appSettings>以下是读取配置的代码:string strConnection=ConfigurationSetting.AppSettings("NWind");
string strCommand="SELECT CategoryID AS [Our Number],CategoryName AS[Category Name],Description AS [Category Includes] FROM CateGories";
SqlConnection Connection=new SqlConnection(strConnection);
SqlCommand Command=new SqlCommand(strCommand,strConnection);运行的时候出现错误
<appSettings>
<add key="NWind"
value="server=127.0.0.1;user id=sa;password=qiujun;database=Northwind"/>
</appSettings>以下是读取配置的代码:string strConnection=ConfigurationSetting.AppSettings("NWind");
string strCommand="SELECT CategoryID AS [Our Number],CategoryName AS[Category Name],Description AS [Category Includes] FROM CateGories";
SqlConnection Connection=new SqlConnection(strConnection);
SqlCommand Command=new SqlCommand(strCommand,strConnection);运行的时候出现错误
解决方案 »
- 如何在不使用webpart情况下实现LiveSpace那样拖放布局(Drag & Drop),保存并显示(关键)出来?
- ajax 正则表达式
- 连接字符正确,cnn.Open()时异常.ExecuteReader 需要打开的并且可用的连接。该连接的当前状态是 Closed
- datagrid与数据集绑定,怎样在该页回送的时候,返回该数据集
- form认证,能不能有两个登录页面?
- 关于Process.GetProcesses拒绝访问的问题
- asp.net中的textbox好像没有onBlur事件,要实现这功能,该怎么办〉
- 怎么将回车换行存入数据库
- [焦头烂额]Linq to entity和视图的执行结果不一样,求解惑!!!
- 好久没有看到思归JJ了。是不是避难去了??
- 关于文件传输的问题,请高手进来指点一下!!!
- 我在页面用一个JS实现删除确定对话提示,但怎么也不对?请帮忙看看,谢谢
找不到类型或命名空间名称"ConfigurationSetting"SqlCommand Command=new SqlCommand(strCommand,strConnection);这句我写错了,应该是
SqlCommand Command=new SqlCommand(strCommand,Connection);