帮我看看这段程序有什么错!谢谢了!!

luosha80 2004-02-24 02:59:49
Imports System.Data '调用DataSet和DataView类所必须的
Imports System.Data.SqlClient '调用SqlConnection,SqlDataAdapter,SqlCommand,SqlParameter类所必须的

Public Class Form1
Inherits System.Windows.Forms.Form

Dim myConnection As SqlConnection = New _
SqlConnection("server = (local);database = pubs;integrated security=true")
Dim myDataAdapter As New SqlDataAdapter()
Dim myDataSet As DataSet = New DataSet()


#Region " Windows 窗体设计器生成的代码 "

Public Sub New()
MyBase.New()

'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()

'在 InitializeComponent() 调用之后添加任何初始化

End Sub

'窗体重写处置以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer

'注意:以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents grdAuthorTitles As System.Windows.Forms.DataGrid
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.grdAuthorTitles = New System.Windows.Forms.DataGrid()
CType(Me.grdAuthorTitles, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'grdAuthorTitles
'
Me.grdAuthorTitles.Anchor = (((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right)
Me.grdAuthorTitles.DataMember = ""
Me.grdAuthorTitles.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.grdAuthorTitles.Location = New System.Drawing.Point(5, 5)
Me.grdAuthorTitles.Name = "grdAuthorTitles"
Me.grdAuthorTitles.Size = New System.Drawing.Size(584, 192)
Me.grdAuthorTitles.TabIndex = 0
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(592, 203)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.grdAuthorTitles})
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Bound DataSet"
CType(Me.grdAuthorTitles, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
myDataAdapter.SelectCommand = New SqlCommand()
myDataAdapter.SelectCommand.Connection = myConnection
myDataAdapter.SelectCommand.CommandText = _
"SELECT au_lname,au_fname,title,price" & _
"FROM authors" & _
"JOIN titleauthor ON authors.au_id = titleauthor.au_id" & _
"JOIN titles ON titleauthor.title_id = titles.title_id" & _
"ORDER BY au_lname,au_fname"
myDataAdapter.SelectCommand.CommandType = CommandType.Text

myConnection.Open()

myDataAdapter.SelectCommand.ExecuteNonQuery()

myDataAdapter.Fill(myDataSet, "authors")

myConnection.Close()

grdAuthorTitles.DataSource = myDataSet
grdAuthorTitles.DataMember = "authors"
End Sub
End Class
...全文
14 点赞 收藏 8
写回复
8 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
相关推荐
发帖
VB
创建于2007-09-28

1.6w+

社区成员

VB技术相关讨论,主要为经典vb,即VB6.0
申请成为版主
帖子事件
创建了帖子
2004-02-24 02:59
社区公告
暂无公告