一程序功能将orders表和Customers表中的字段绑定到文本框
二窗体设计
新建ASPNET Web应用程序命名为Sql选择保存路径然后点击确定
向窗体中添加两个Label和两个Textbox控件窗体界面见下图
三代码设计
切换到代码窗口添加代码如下
Imports SystemDataSqlClient
Public Class WebForm
Inherits SystemWebUIPage
Private Sub Page_Load(ByVal sender As SystemObject ByVal e As SystemEventArgs) Handles MyBaseLoad
Dim scon As New SqlConnection(server=localhost;database=northwind;integrated security=true)
Dim i As Integer =
创建一个数据适配器查询订单表中的订单号和客户表的公司名称此处使用了表格别名
Dim sda As New SqlDataAdapter _
(select oorderid panyname from orders o customers c where ocustomerid=ccustomerid and oorderid= & iToString scon)
Dim ds As New DataSet
Try
sdaFill(ds)
Catch ex As Exception
End Try
绑定数据
TextBoxText = dsTables()Rows()Item()
TextBoxText = dsTables()Rows()Item()
End Sub
End Class