vb.net 连接 access 数据库

前端之家收集整理的这篇文章主要介绍了vb.net 连接 access 数据库前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
查询代码
Imports System.Data.OleDb
	Try
                Dim Con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=contract.accdb")
                Con.Open()
                '开始查询 
                Dim sql As String = "SELECT 合同编号 FROM contract"
                Dim objCommand As New OleDbCommand(sql,Con)
                Dim objReader As OleDbDataReader = objCommand.ExecuteReader()
                Dim strData As String

                If objReader.HasRows Then
                    While objReader.Read()
                        strData = String.Empty
                        For intIndex As Integer = 0 To objReader.FieldCount - 1
                            strData &= objReader.Item(intIndex).ToString & ","
                        Next
                    End While
                End If
                objReader.Close()
                objCommand.Dispose()
                Con.Close()
                'TextBox8.Text = strData
            Catch ex As Exception
                MessageBox.Show(ex.Message,"access")
            End Try

猜你在找的VB相关文章