请问你在web.config中appsetting节点里面"NorthwindConnection"的数据库连接有没有
解决方案 »
- JS 取值问题-在线结贴
- iframe使用疑问
- 请问如何在gridview中实现此功能,谢谢
- asp.net
- 接收页面控件里的数据(非拖拉控件的数据)
- 谢!!!!!!!!!!!DataGrid分页从未出现过的问题``今天被我碰到了``郁闷```
- 我的一个设想的可行性?
- 请问思归大哥,为什么带了参数就不行了?
- 在SqlDataAdapter.Fill(dataset,table)时出现未能启用约束。一行或多行中包含违反非空、唯一或外键约束的值???
- Ajax中 在删除数据之后,页面显示成功,但是删除的数据还是在本页,如何才能实现本页面的删除??跪求
- 在ASP.NET中调用WebService中的方法时,传递参数的问题
- 请高手指教,关于DataGrid!
<AppSettings>
<add key="NorthwindConnection" value="............." />
</appSettings>
是用来设置整个站点的数据库连接的,你写了没有
找到web.config文件,看到第一行是<?xml version="1.0" encoding="utf-8" ?>
第二行是<configuration>,如果你没有看到刚才我提到的那个节点,那么你在第三行把 <AppSettings>
<add key="NorthwindConnection" value="Server=Localhost;Trusted_Connection=True;database=数据库名" />
</AppSettings>
添加进去,其中"数据库名"换成你自己的数据库名就行了。如果有这个节点就替换。
<AppSettings>
<add key="NorthwindConnection" value="Server=Localhost;Trusted_Connection=True;database=Northwind" />
</AppSettings>报错 Error while trying to run project: Unable to start debugging on the web server......
Verify there are no syntax errors in web.config by doing a Debug.
Login failed for user 'LZHANG\ASPNET'. Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'LZHANG\ASPNET'.我在那行加了 ID 和 Password, 还是那样。<add key="NorthwindConnection" value="Server=Localhost;User ID=sa;Password=;Trusted_Connection=True;database=Northwind" />
设:
Trusted_Connection=False但是不能翻页,也不能排序。能再帮助看看吗?html 的全部 code:(DGPageSort.aspx 的程序在楼顶。)<%@ Page Language="vb" Src="DGPageSort.aspx.vb" Inherits="DGPageSort"%>
<html>
<head>
<title>Paging and Sorting in a DataGrid</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body>
<h3><font face="Verdana">Paging and Sorting in a DataGrid</font></h3>
<form ID="form1" runat="server">
<asp:Label id="lblOrderBy" runat="server" Visible="False" />
<asp:DataGrid id="dtgCusts"
Width="700"
Cellpadding="2"
Cellspacing="0"
Gridlines="Horizontal"
HeaderStyle-BackColor="IndianRed"
HeaderStyle-Font-Bold="True"
HeaderStyle-Font-Name="Verdana"
HeaderStyle-Font-Size="12px"
HeaderStyle-ForeColor="White"
ItemStyle-BackColor="Gainsboro"
ItemStyle-Font-Name="verdana"
ItemStyle-Font-Size="12px"
AllowPaging="True"
OnPageIndexChanged="PageIndexChanged_Click"
PageSize="10"
PagerStyle-Mode="NumericPages"
PagerStyle-Position="Top"
PagerStyle-HorizontalAlign="Center"
PagerStyle-CssClass="pageLinks"
AllowSorting="True"
OnSortCommand="SortCommand_Click"
runat="server" />
</form>
</body>
</html>
十分感谢“光光”的热心帮助。
还有疑问:
如果我将那个 select * from .... 改为 store procedure 是否很麻烦,
因为我的表有 3 个,如果不改,这一行是否要增加表名:dtgCusts.DataSource = myDataSet.Tables("Customers")改为:
dtgCusts.DataSource = myDataSet.Tables("Customers,Sales,Employees")再次感谢!
2。改成stored procedure一开始是有点麻烦,但是会带给你很多好处。
你的datasource在stored procedure里面完全可以用联合查询来解决,类似
select ...from Customers,Sales,Employees 来解决