连接 MSSQL Server 2000及以上版本的数据库
Imports System.Data.SqlClient
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'与MSSQL Server数据库连接
Dim sqlCon As New SqlConnection
sqlCon.ConnectionString = "data source=127.0.0.1;initial catalog=stepSample;user id =sa;password=123"
sqlCon.Open()
end sub
连接 access 2007-access2010数据库
Imports System.Data.OleDb
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'与ACCESS2007及更高版本数据库连接,
Dim accdbCon As New OleDbConnection
accdbCon.ConnectionString = "provider=Microsoft.ace.oledb.12.0;data source=J:\vb10sbs\chap18\Faculty2010.accdb"
accdbCon.Open()
End Sub
连接Access2003数据库
Import