189 8069 5689

vb。net制作mdb vbnet mybase

怎样用VB.NET 做学生管理系统

1:Access,建立数据库,数据库命名为Database1.mdb。

创新互联服务项目包括长兴网站建设、长兴网站制作、长兴网页制作以及长兴网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,长兴网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到长兴省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!

(注意:这里的后缀是MDB,如果Access是2007版本的,保存的时候要另存为2003版本的才行,因为,VB不直接支持07版的accdb后缀格式!)

2:数据库建立后就进入了数据表界面,可以输入数据了,输完以后CRRL+S保存,输入表名,这里表名为test,ok,准备工作搞定。

菜单中找到工程→部件→勾选 ,

Microsoft ADO Data Control 6.0

Microsoft Hierarchical Flexgrid Control 6.0

勾选后左侧工具栏里就多了两个控件即 ADODC控件和MSHFlexGrid控件。

选择 ADODC控件和MSHFlexGrid控件,放在窗体的合适位置

设置ADODC控件的属性:

右键窗体内ADODC1控件

1:ADODC属性页→通用→选择使用连接字符串→点击生成→选择Microsoft Jet 4.0 OLE DB Provider 点击下一步→选择之前准备好的数据库→点击测试连接,显示测试成功则ok,确定。

2:ADODC属性页→记录源→命令类型选择2-adcmdtable,表或存储过程名称选择之前建立的数据表test,点击确定,ADODC属性设置完成。

设置MSHFlexGrid控件的属性:

VB右侧属性表里,找到datasource,选择adodc1

就完事了

般电话机对外联络,以免为了穿透墙壁天花板等障碍而浪费电。同样在室外

VB.NET如何生成ACCESS数据库?并生成表。 VB.NET

我的需求就是先填写好表和表中字段的名称,然后点击一个按钮,就在指定的路径生成一个ACCESS数据库。而不是事先手动创建。 请知道的各位附上完整代码,本人刚接触VB.NET,有些东西还不是很了解。谢谢。

vb.net 写入mdb数据库

1、首先,你得做一个oledbconnection对象,这个对象有个连接字符串的属性,你需要设置

2、做一个oledbcommand对象,这个对象有个操作字符串(SQL语句)需要设置

3、打开oledbconnection对象

4、执行oledbcommand对象

5、关闭oledbconnection对象

程序结束,希望对你有帮助

用vb.net操作access数据库

mports System.Drawing

Imports System.ComponentModel

Imports System.Windows.Forms

Imports System.Data.OleDb

Imports System.Data

Public Class Form1

Inherits Form

Private components As System.ComponentModel.Container = Nothing

Private WithEvents lastrec As Button

Private WithEvents nextrec As Button

Private WithEvents previousrec As Button

Private WithEvents firstrec As Button

Private t_books As TextBox

Private t_nl As TextBox

Private t_xb As TextBox

Private t_xm As TextBox

Private t_id As TextBox

Private l_books As Label

Private l_nl As Label

Private l_xb As Label

Private l_xm As Label

Private l_id As Label

Private label1 As Label

Private myDataSet As DataSet

Private WithEvents button1 As Button

Private WithEvents button2 As Button

Private WithEvents button3 As Button

Private WithEvents button4 As Button

Private myBind As BindingManagerBase

Public Sub New ( )

MyBase.New ( )

GetConnected ( )

InitializeComponent ( )

End Sub

'清除在程序中使用过的资源

Protected Overloads Overrides Sub Dispose (ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose ( )

End If

End If

MyBase.Dispose ( disposing )

End Sub

Public Sub GetConnected ( )

'创建一个数据连接

Dim strCon As String = " Provider = Microsoft.Jet.OLEDB.4.0 ;

Data Source = db.mdb "

Dim myConn As OleDbConnection = New OleDbConnection ( )

myConn.ConnectionString = strCon

Dim strCom As String = " SELECT * FROM person "

'创建一个 DataSet

myDataSet = New DataSet ( )

myConn.Open ( )

'通过OleDbDataAdapter对象得到一个数据集

Dim myCommand As OleDbDataAdapter = New OleDbDataAdapter

( strCom , myConn )

'把Dataset绑定books数据表

myCommand.Fill ( myDataSet , "person" )

'关闭此数据连接

myConn.Close ( )

End Sub

'插入数据记录操作代码

Private Sub button2_Click (ByVal sender As Object , _

ByVal e As System.EventArgs) Handles button2.Click

'判断所有字段是否添完,添完则执行,反之弹出提示

If ( t_id.Text "" And t_xm.Text ""

And t_xb.Text "" And t_nl.Text ""

And t_books.Text "" ) Then

Dim myConn1 As String = " Provider = Microsoft.Jet.OLEDB.4.0 ;

Data Source = db.mdb"

Dim myConn As OleDbConnection = New OleDbConnection ( myConn1 )

myConn.Open ( )

Dim strInsert As String = " INSERT INTO person ( id , xm , xb , nl

, zip ) VALUES ( " _

t_id.Text + " , '" _

t_xm.Text + "' , '" _

t_xb.Text + "' , " _

t_nl.Text + " , " _

t_books.Text + ")"

Dim inst As OleDbCommand = New OleDbCommand ( strInsert , myConn )

inst.ExecuteNonQuery ( )

myConn.Close ( )

myDataSet.Tables ( "person" ).Rows ( myBind.Position ).BeginEdit ( )

myDataSet.Tables ( "person" ).Rows ( myBind.Position ).EndEdit ( )

myDataSet.Tables ( "person" ).AcceptChanges ( )

Else

MessageBox.Show ( "必须填满所有字段值!" , "错误!" )

End If

End Sub


当前名称:vb。net制作mdb vbnet mybase
标题URL:http://cdxtjz.cn/article/dojipec.html

其他资讯