设为首页
联系我们
加入收藏
| 网络工具 | 系统工具 | 应用软件 | 多媒体类 | 联络聊天 | 行业软件 | 图形图像 | 安全相关 | 编程开发 | 教育教学 | 游戏娱乐 |
| 程序源码 | ASP 源码 | CGI 源码 | PHP 源码 | 驱动下载 | 字体下载 | 素材下载 | 桌面大全 | 闪客天地 | 外挂插件 | 考题下载 |

站内搜索:

您的位置:首页-> 资讯中心-> 技术开发-> .Net 专栏-> ASP.NET开发-> ASP+中执行简单的Select查询,并返回数据表到DataGrid源程序

ASP.NET开发

ASP.NET开发
.NET概论
C#语言
数据库应用

本类阅读TOP10

·如何在DataGrid控件中实现编辑、删除、分类以及分页操作
·在 ASp+ 中的一些可能会用到的小函数
·用ASP.NET动态生成图像(转1)
·asp+ VB上传文件代码
·在ASP.NET中处理 datetime 的一些通用函数(vb)
·Asp.net编写的PING工具
·asp+中的hash表操作
·一个asp+ 版本的 Active Server Explorer
·用ASP.Net写一个发送ICQ信息的程序
·一个简单的ASP+留言板程序

精品推荐

ASP+中执行简单的Select查询,并返回数据表到DataGrid源程序

作者:未知 来源:未知 加入时间:2004-12-1

------------------c#源程序----------------
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQL" %>

<html>
<script language="C#" runat="server">

protected void Page_Load(Object Src, EventArgs E)
{
SQLConnection myConnection = new SQLConnection("server=localhost;uid=sa;pwd=;database=pubs");
SQLDataSetCommand myCommand = new SQLDataSetCommand("select * from Authors", myConnection);

DataSet ds = new DataSet();
myCommand.FillDataSet(ds, "Authors");

MyDataGrid.DataSource=ds.Tables["Authors"].DefaultView;
MyDataGrid.DataBind();
}

</script>

<body>

<h3><font face="Verdana">Simple Select to a DataGrid Control</font></h3>

<ASP:DataGrid id="MyDataGrid" runat="server"
Width="700"
BackColor="#ccccff"
BorderColor="black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
MaintainState="false"
/>

</body>
</html>

------------#VB源程序---------------
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQL" %>

<html>
<script language="VB" runat="server">

Sub Page_Load(Src As Object, E As EventArgs)

Dim DS As DataSet
Dim MyConnection As SQLConnection
Dim MyCommand As SQLDataSetCommand

MyConnection = New SQLConnection("server=localhost;uid=sa;pwd=;database=pubs")
MyCommand = New SQLDataSetCommand("select * from Authors", MyConnection)

DS = new DataSet()
MyCommand.FillDataSet(ds, "Authors")

MyDataGrid.DataSource=ds.Tables("Authors").DefaultView
MyDataGrid.DataBind()
End Sub

</script>

<body>

<h3><font face="Verdana">Simple Select to a DataGrid Control</font></h3>

<ASP:DataGrid id="MyDataGrid" runat="server"
Width="700"
BackColor="#ccccff"
BorderColor="black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
MaintainState="false"
/>

</body>
</html>

(出处:不详 )





相关文章
相关软件