2
Contributors
1
Reply
5
Views
6 Years
Discussion Span
Last Post by ericko10kip
0

Login form contain two nos.of textbox anb one no.button How to connect VB.net2008 with MS-Access-2007.

you add a module to your project then paste the following code.make sure to highlight this default code
module module1

End module
and you replace it.

Imports System.Data
Imports System.Data.OleDb
Imports System.Console
Imports System.Data.OleDb.OleDbDataReader

Module Module1
Public Sub Database_connection()
Try
Cnn.ConnectionString = "Provider=Microsoft.Jet.OleDb.4.0;" & "Data Source=" & Application.StartupPath & "\databasename.mdb"
Cnn.Open()
Com.Connection = Cnn
Com.CommandType = CommandType.Text
Catch ex As Exception
MsgBox(ex.Message)
End Try
'make sure you have your database in the bin folder onside your project.
End Sub

Public Sub closeconnection()
Cnn.Close()
End Sub
End Module

You don't mind to change anything.then you call the function Database_connection()
either on form load.e.g(you double click the form then type Database_connection(.)

I hope this will help you.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.