VB2008.NET DataGrid相关总结1
发布时间:2020-12-16 23:12:39 所属栏目:大数据 来源:网络整理
导读:VB2008.NET DataGrid相关总结1 1。DataGrid是VB6.0里的。如果VB2008中要用必须先添加ActiveX控件。 在 VB.net 中右键工具箱,选择 2.连接数据库代码 Access数据库 Public Class Form1 Inherits System.Windows.Forms.Form Dim Con As New ADODB.Connection()
VB2008.NET DataGrid相关总结1
1。DataGrid是VB6.0里的。如果VB2008中要用必须先添加ActiveX控件。 在VB.net中右键工具箱,选择
2.连接数据库代码
Access数据库 Public Class Form1 Inherits System.Windows.Forms.Form Dim Con As New ADODB.Connection() Dim Rec As New ADODB.Recordset() Private Sub Form1_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Load Con.ConnectionString = "Dbq=" & Application.StartupPath & "/Test.mdb;Driver={Microsoft Access Driver (*.mdb)}" Con.Open() Rec.CursorType = 1 Rec.LockType = 3 Rec.ActiveConnection = Con Rec.Open("Student") '("Select * From Student",Con) AxDataGrid1.DataSource = Rec AxDataGrid1.Refresh() End Sub Private Sub Form1_Leave(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Leave Rec.Close() Con.Close() Rec = Nothing Con = Nothing End Sub End Class
3.运行程序后 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |