''
Me.DataGrid1.DataMember = ""
Me.DataGrid1.Location = New System.Drawing.Point(40, 56)
Me.DataGrid1.Name = "DataGrid1"
Me.DataGrid1.Size = New System.Drawing.Size(480, 264)
Me.DataGrid1.TabIndex = 3
''
''Form1
''
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(568, 429)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.DataGrid1, Me.Button3, Me.Button2, Me.Button1})
Me.Name = "Form1"
Me.Text = "Form1"
CType(Me.Client_DataSet, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Customer_Ds As New localhost.super_ds()
Dim ser1 As New localhost.Service1()
Customer_Ds.Merge(ser1.Get_Dataset)
DataGrid1.DataSource = Customer_Ds
End Sub
End Class
总结:可见,表示层窗体上完全没有数据库连接控件,它与数据库的连接任务是通过业务层来完成的,这样,程序的结构更加清晰,当然业务层的实现也可以用其他方法,比如:写一个自己的类来完成与数据库的数据传输。
(转自51dotnet)