您现在的位置是:首页
>
表别名 ASP.NET中使用表别名的多表查询
ASP.NET中使用表别名的多表查询 一 程序功能 将order 表和Cu tomer 表中的字段绑定到文本框 二 窗体设计 新建ASP NET We 应用程序 命名为Sql 选择保

ASP.NET中使用表别名的多表查询
一 程序功能 将orders表和Customers表中的字段绑定到文本框 二 窗体设计 新建ASP NET Web应用程序 命名为Sql 选择保存路径然后点击确定 向窗体中添加两个Label和两个Textbox控件 窗体界面见下图 三 代码设计 切换到代码窗口 添加代码如下 Imports System Data SqlClient Public Class WebForm 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 = 创建一个数据适配器 查询订单表中的订单号和客户表的公司名称 此处使用了表格别名 Dim sda As New SqlDataAdapter _ ( select o orderid panyname 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 绑定数据 TextBox Text = ds Tables( ) Rows( ) Item( ) TextBox Text = ds Tables( ) Rows( ) Item( ) End Sub End Class lishixinzhi/Article/program/net/201311/13439 很赞哦! (1075)