您现在的位置: 天极网 > 开发频道 > 微软开发专栏 > ASP.NET中使用表别名的多表查询
全文

ASP.NET中使用表别名的多表查询

2005-01-29 13:10作者:waterswea出处:天极网责任编辑:方舟
  下载本文源代码

  一、程序功能:将orders表和Customers表中的字段绑定到文本框

  二、窗体设计

  1、新建ASP.NET Web应用程序,命名为Sql4,选择保存路径然后点击确定。

  2、向窗体中添加两个Label和两个Textbox控件,窗体界面见下图

  三、代码设计

  切换到代码窗口,添加代码如下:

Imports System.Data.SqlClient
Public Class WebForm1
Inherits System.Web.UI.Page

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 Dim scon As New SqlConnection("server=localhost;database=northwind;integrated security=true")
 Dim i As Integer = 10248
 '创建一个数据适配器,查询订单表中的订单号和客户表的公司名称,此处使用了表格别名
 Dim sda As New SqlDataAdapter _
("select o.orderid, c.companyname from orders o, customers c where o.customerid=c.customerid and o.orderid=" & i.ToString, scon)
 Dim ds As New DataSet
 Try
  sda.Fill(ds)
 Catch ex As Exception
 End Try
 '绑定数据

 TextBox1.Text = ds.Tables(0).Rows(0).Item(0)
 TextBox2.Text = ds.Tables(0).Rows(0).Item(1)
End Sub
End Class

软件资讯·软件下载尽在天极软件

相关搜索:
关注此文读者还看过
热门关注
特别推荐
网友关注
软件下载
娱乐下载
驱动下载
文章排行
本周
本月
最近更新
关于我们|About us|网站律师|天极服务|电子杂志|RSS订阅|加入我们|网站地图
TMG
Copyright (C) 1999-2009 Chinabyte.com, All Rights Reserved 版权所有 天极网络
商务联系、网站内容、合作建议:010-82657868
版权声明 在线提交意见反馈 渝ICP证B2-20030003号
经营性网站备案信息 网警备案 中国网站排名
天极传媒:天极网|比特网|IT专家网|IT商网|52PK游戏网|IT分众