主题:求助,VB.net与ACCESS登录界面如何制作
sunnyasa
[专家分:0] 发布于 2007-01-01 12:32:00
最近想做一程序,需要一用户登录界面,无奈不会和数据库ACCESS连接,求助!~!~
回复列表 (共1个回复)
沙发
linxuanxu [专家分:9360] 发布于 2007-01-19 23:28:00
//在窗体上画一个按钮 button1
//将数据库例如:mydb.mdb 放在 bin\Debug 下
//运行
Public Class Form1
Dim conn As System.Data.OleDb.OleDbConnection
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button1.Text = "连接到Access数据库"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim thelinkText As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=mydb.mdb"
Try
conn = New OleDb.OleDbConnection(thelinkText)
conn.Open()
MsgBox("数据库连接成功,并以打开")
Catch ex As Exception
MsgBox("连接失败,请检查数据库是否存在、路径是否正确:" + vbCrLf + thelinkText)
End Try
End Sub
End Class
我来回复