btcq.net
当前位置:首页 >> VB.NEt连接ACCEss数据库 >>

VB.NEt连接ACCEss数据库

使用向导设置数据库连接的好处是省去写代码的过程,弊端是不易更改连接 使用代码连接的好处是需要编写代码,但容易更改和维护 如:数据库的位置变化,直接更改代码显然容易一些 代码:imports system.data.oledb /*引用命名空间*/ dim

1、定义连接字符串并连到数据库2、取出数据到Dataset并绑定到DataGrid3、DataSet本身就是断开的

给你写个例子,不明白,再问!!'引入OLEDB命令空间 Imports System.Data.OleDb Public Class Form1 Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click '定义一个OLEDB连接并实例化它 Dim

Provider=Microsoft.ACE.OLEDB.4.0;Data Source=|DataDirectory|\Temp\aaa.accdb;Persist Security Info=True 或 Provider=Microsoft.ACE.OLEDB.4.0;Data Source=|DataDirectory|\Temp\aaa.accdb;Persist Security Info=True 或 Provider

TextBox1.Text=Rs.fields(0)换成TextBox1.Text=Rs.fields("具体的字段名")s试试!

链接要用到控件有OleDbConnection,其语法为:OleDbConnection.ConnectionString="provider=microsoft.jet.oledb.4.0;data source=数据库.mdb"OleDbConnection.open()就两句

Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\Data.mdb" Dim myConn As OleDbConnection = New OleDbConnection(strConn) myConn.Open() Dim TestCommand As

把这两个文本框也绑定DataGridView1 用的那个数据源就可以了,ID对ID name对name 绑定就可以同步了

dim conn as new System.Data.Oledb.OledbConnection("provider='microsoft.ole.jet.4.0' data source='路径';uid=''pwd=''"); conn.open(); provider='microsoft.ole.jet.4.0' 可能有错误 自己查查吧.忘记了

Private Function getAccessConnection() As OleDbConnection Dim dbConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=|DataDirectory|\Resources\mag.mdb;Persist Security Info=true" Dim dbConnection As

fpbl.net | xcxd.net | clwn.net | beabigtree.com | zmqs.net | 网站首页 | 网站地图
All rights reserved Powered by www.btcq.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com