有如下代码,看看有什么问题?
<%@ import namespace="system.data" %>
<%@ import namespace="system.data.sql" %>
<!--DataSet 要引用system.data,数据库连接要用到system.data.sql-->
<html><script language="vb" runat=server> sub Page_Load(o as object,e as eventargs)
dim MyConnection as SQLConnection
dim MyStr as String
dim MyDataSetCommand as SQLDataSetCommand
dim MyDataSet as New DataSet If Not IsPostBack MyConnection=New SQLConnection("server=localhost;uid=sa;pwd=z1x2c3;database=pubs") MyStr="Select au_lname,au_fname from authors" MyDataSetCommand=New SQLDataSetCommand(Mystr,MyConnection)
MyDataSetCommand.FillDataSet(MyDataSet,"Authors") Session("MyDs")=MyDataSet Else
MyDataSet=Session("MyDs") if MyDataSet is Nothing
Response.Write("无法取得数据")
else
Select Case DpDnLst.SelectedItem.text
case "Repeater"
Response.write _
("<center>以<I>Repeater</I>控件显示数据</center>")
db1.datasource=MyDataSet.tables("authors").defaultview
db1.databind
panel1.visible=True
panel2.visible=False
panel3.visible=False
case "DataList"
Response.write _
("<center>以<B>DataList</B>控件显示数据</center>")
db2.datasource=MyDataSet.tables("authors").defaultview
db2.databind panel1.visible=False
panel2.visible=True
panel3.visible=False
case "DataGrid"
Response.write _
("<center>以<U>DataGrid</U>控件显示数据</center>")
db3.datasource=MyDataSet.tables("authors").defaultview
db3.databind panel1.visible=False
panel2.visible=False
panel3.visible=True case else
End Select end if
End If
end sub
</script>
<head>
<title>
数据绑定技术试验
</title>
</head><body bgcolor=#ffffff>
<center>
<h2>DataSource试验</h2>
<hr> <form runat=server>
请选择控件类型:
<asp:DropDownList id="DpDnLst" runat=server>
<asp:Listitem>Repeater</asp:Listitem>
<asp:Listitem>DataList</asp:Listitem>
<asp:Listitem>DataGrid</asp:Listitem>
</asp:DropDownList>
<asp:button text="提交" runat=server/>
<hr> <!--定义三个画板,根据下拉列表的选择,使指定的画板可见--> <!-- 画板一 :定义一个Repeater控件 -->
<asp:panel id="panel1" visible=false runat=server>
<asp:repeater id="db1" runat=server>
<!--定义Repeater控件显示的表头 -->
<template name="headertemplate">
<table>
<tr>
<td>
姓氏
</td>
<td>
名字
</td>
</tr>
</template> <!--定义Repeater控件数据显示的格式 -->
<template name="itemtemplate">
<tr>
<td>
<%# databinder.eval(container.dataitem,"au_lname") %>
</td>
<td>
<%# databinder.eval(container.dataitem,"au_fname") %>
</td>
</tr>
</template> <!--定义Repeator控件显示的表尾 -->
<template name="footertemplate">
</table>
</template>
</asp:repeater>
</asp:panel> <!-- 画板二:定义一个DataList控件 -->
<asp:panel id="panel2" visible=false runat=server>
<asp:datalist id="db2" runat=server>
<!--定义datalist的显示格式为:姓氏----名字 -->
<template name="itemtemplate">
<%# databinder.eval(container.dataitem,"au_lname") %>
----
<%# databinder.eval(container.dataitem,"au_fname") %>
<br>
</template>
</asp:datalist>
</asp:panel> <!-- 画板三:定义一个DataGrid控件 -->
<asp:panel id="panel3" visible=false runat=server>
<asp:datagrid id="db3" runat=server>
</asp:datagrid>
</asp:panel> </form>
</center>
</body>
</html>
错误有如下提示:Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
<%@ import namespace="system.data" %>
<%@ import namespace="system.data.sql" %>
<!--DataSet 要引用system.data,数据库连接要用到system.data.sql-->
<html><script language="vb" runat=server> sub Page_Load(o as object,e as eventargs)
dim MyConnection as SQLConnection
dim MyStr as String
dim MyDataSetCommand as SQLDataSetCommand
dim MyDataSet as New DataSet If Not IsPostBack MyConnection=New SQLConnection("server=localhost;uid=sa;pwd=z1x2c3;database=pubs") MyStr="Select au_lname,au_fname from authors" MyDataSetCommand=New SQLDataSetCommand(Mystr,MyConnection)
MyDataSetCommand.FillDataSet(MyDataSet,"Authors") Session("MyDs")=MyDataSet Else
MyDataSet=Session("MyDs") if MyDataSet is Nothing
Response.Write("无法取得数据")
else
Select Case DpDnLst.SelectedItem.text
case "Repeater"
Response.write _
("<center>以<I>Repeater</I>控件显示数据</center>")
db1.datasource=MyDataSet.tables("authors").defaultview
db1.databind
panel1.visible=True
panel2.visible=False
panel3.visible=False
case "DataList"
Response.write _
("<center>以<B>DataList</B>控件显示数据</center>")
db2.datasource=MyDataSet.tables("authors").defaultview
db2.databind panel1.visible=False
panel2.visible=True
panel3.visible=False
case "DataGrid"
Response.write _
("<center>以<U>DataGrid</U>控件显示数据</center>")
db3.datasource=MyDataSet.tables("authors").defaultview
db3.databind panel1.visible=False
panel2.visible=False
panel3.visible=True case else
End Select end if
End If
end sub
</script>
<head>
<title>
数据绑定技术试验
</title>
</head><body bgcolor=#ffffff>
<center>
<h2>DataSource试验</h2>
<hr> <form runat=server>
请选择控件类型:
<asp:DropDownList id="DpDnLst" runat=server>
<asp:Listitem>Repeater</asp:Listitem>
<asp:Listitem>DataList</asp:Listitem>
<asp:Listitem>DataGrid</asp:Listitem>
</asp:DropDownList>
<asp:button text="提交" runat=server/>
<hr> <!--定义三个画板,根据下拉列表的选择,使指定的画板可见--> <!-- 画板一 :定义一个Repeater控件 -->
<asp:panel id="panel1" visible=false runat=server>
<asp:repeater id="db1" runat=server>
<!--定义Repeater控件显示的表头 -->
<template name="headertemplate">
<table>
<tr>
<td>
姓氏
</td>
<td>
名字
</td>
</tr>
</template> <!--定义Repeater控件数据显示的格式 -->
<template name="itemtemplate">
<tr>
<td>
<%# databinder.eval(container.dataitem,"au_lname") %>
</td>
<td>
<%# databinder.eval(container.dataitem,"au_fname") %>
</td>
</tr>
</template> <!--定义Repeator控件显示的表尾 -->
<template name="footertemplate">
</table>
</template>
</asp:repeater>
</asp:panel> <!-- 画板二:定义一个DataList控件 -->
<asp:panel id="panel2" visible=false runat=server>
<asp:datalist id="db2" runat=server>
<!--定义datalist的显示格式为:姓氏----名字 -->
<template name="itemtemplate">
<%# databinder.eval(container.dataitem,"au_lname") %>
----
<%# databinder.eval(container.dataitem,"au_fname") %>
<br>
</template>
</asp:datalist>
</asp:panel> <!-- 画板三:定义一个DataGrid控件 -->
<asp:panel id="panel3" visible=false runat=server>
<asp:datagrid id="db3" runat=server>
</asp:datagrid>
</asp:panel> </form>
</center>
</body>
</html>
错误有如下提示:Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
解决方案 »
- 求助:无法创建ASP.NET MVC 1.0工程
- IIS下web.config何去何从的问题!!!
- xp系统安装虚拟机,安装server2003系统
- 问两表多次级联查询的SQL语句
- 地址的加密方法
- 关于模型层的问题?
- datagrid为我的用户控件(实现站内搜索)的一部分,搜索出来的datagrid中的内容会被当前页面的panel,label等控件覆盖掉,并且会先触发验证控
- [求助]~~在ASP.NET里面怎么实现“退出系统”?~~~~
- ====想做一个效果,不知道那位同学有没有代码,供参考!========
- 用C#能不能实现然让文本一个字一个字的弹出????
- 有没有什么控件可以将数据写入Excel模板的
- .Net 2005 怎么样?
dim MyDataSetCommand as SQLDataSetCommandSQLDataSetCommand是个什么东西啊,应该是用SqlDataAdapter