VB2008.NET DataGrid相关总结1
1。DataGrid是VB6.0里的。如果VB2008中要用必须先添加ActiveX控件。
在VB.net中右键工具箱,选择
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.运行程序后
原文链接:https://www.f2er.com/vb/262145.html