944,139 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 13226
  • VB.NET RSS
You are currently viewing page 1 of this multi-page discussion thread
Oct 18th, 2006
0

I need help for connecting to Ms access database

Expand Post »
Hi ,I work with vb.net 2005 . I want to know if I want to connect to data base with Ms Access which data source i can use (ODBC or OLEDB)
I write the following code in form load event (by OLEDB) :

Dim conn As New OleDb.OleDbConnection("Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDBdatabase Locking Mode=1;Jet OLEDBdatabase Password=;Data Source=C:\Program Files\Microsoft Office\Office11\Samples\Northwind.mdb;Password=;Jet OLEDB:Engine Type=5;Jet OLEDB:Global Bulk Transactions=1;Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDBystem database=;Jet OLEDBFP=False;Extended Properties=;Mode=Share Deny None;Jet OLEDB:New Database Password=;Jet OLEDB:Create System Database=False;Jet OLEDBdon't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:Encrypt Database=False")

Dim da As New OleDb.OleDbDataAdapter("select * from orders", conn)
Dim ds As New DataSet
da.Fill(ds)

and have an error that "OledbException was unhandled"
How can i solve this error or How can connect with ODBC data source to MS access data base.
I will happy if anyone can help me.
Thank You , MOJAL
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mojal67 is offline Offline
3 posts
since Oct 2006
Oct 18th, 2006
0

Re: I need help for connecting to Ms access database

Two things. Use the IDE to get the correct connection string. It seems a bit long with a lot of unnecessary options for Jet Database. Then make sure you ALWAYS put your connection in a Try/Catch block. This is the only way to handle exceptions.

Andy
Reputation Points: 14
Solved Threads: 5
Junior Poster
nicentral is offline Offline
166 posts
since Apr 2005
Oct 18th, 2006
0

Re: I need help for connecting to Ms access database

Quote originally posted by mojal67 ...
Hello Andy Thank you very much for your answer dear andy i do your suggestion but i dont have any connection to ms access database also i dont have any error because of your desribtion. can you help me more please
i hope have a nice life with the God protection.
:p Mojal
Mojal --

try changing the code to

Dim conn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb")

if it still doesn't work, you might have the wrong path for your database file.

-- Andy
Reputation Points: 14
Solved Threads: 5
Junior Poster
nicentral is offline Offline
166 posts
since Apr 2005
Oct 20th, 2006
0

Re: I need help for connecting to Ms access database

try something like this......

Private currpath As String = System.Environment.CurrentDirectory
Private connService As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source= " & currpath & "\ServiceCalls.mdb")
Public daCustomers As New System.Data.OleDb.OleDbDataAdapter("Select * from Customers", connService)
Public daCalls As New System.Data.OleDb.OleDbDataAdapter("Select * from Calls ORDER BY CustomerID", connService)
Private daCallStatus As New System.Data.OleDb.OleDbDataAdapter("Select * from Status", connService)
Private cbCustomers As New System.Data.OleDb.OleDbCommandBuilder(daCustomers)
Private cbCalls As New System.Data.OleDb.OleDb
Reputation Points: 10
Solved Threads: 1
Light Poster
SethR is offline Offline
33 posts
since Oct 2005
Jun 17th, 2008
0

Re: I need help for connecting to Ms access database

Hi Mojal:

I am new to database too. Can you please tell me as to where I need to type the code that you have (for database connectivity) ? Is it typed in the form_load procedure ?

It will be nice if you can reply ASAP. you can email me at kukki.kanchana@gmail.com
















Click to Expand / Collapse  Quote originally posted by mojal67 ...
Hi ,I work with vb.net 2005 . I want to know if I want to connect to data base with Ms Access which data source i can use (ODBC or OLEDB)
I write the following code in form load event (by OLEDB) :

Dim conn As New OleDb.OleDbConnection("Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDBdatabase Locking Mode=1;Jet OLEDBdatabase Password=;Data Source=C:\Program Files\Microsoft Office\Office11\Samples\Northwind.mdb;Password=;Jet OLEDB:Engine Type=5;Jet OLEDB:Global Bulk Transactions=1;Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDBystem database=;Jet OLEDBFP=False;Extended Properties=;Mode=Share Deny None;Jet OLEDB:New Database Password=;Jet OLEDB:Create System Database=False;Jet OLEDBdon't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:Encrypt Database=False")

Dim da As New OleDb.OleDbDataAdapter("select * from orders", conn)
Dim ds As New DataSet
da.Fill(ds)

and have an error that "OledbException was unhandled"
How can i solve this error or How can connect with ODBC data source to MS access data base.
I will happy if anyone can help me.
Thank You , MOJAL
Reputation Points: 10
Solved Threads: 0
Junior Poster
kavithabhaskar is offline Offline
123 posts
since Jun 2008
Jun 17th, 2008
0

Re: I need help for connecting to Ms access database

Mojal:

Thanks in Advance!
Reputation Points: 10
Solved Threads: 0
Junior Poster
kavithabhaskar is offline Offline
123 posts
since Jun 2008
Jun 17th, 2008
0

Re: I need help for connecting to Ms access database

Folks:
I am new to VB and I am using VB.NET.Can anyone please tell me as to where the code for setting up the database connection needs to be typed?

If you can reply ASAP, it will be greatly appreciated.

Thanks,
Kavitha.
Reputation Points: 10
Solved Threads: 0
Junior Poster
kavithabhaskar is offline Offline
123 posts
since Jun 2008
Jun 17th, 2008
0

Re: I need help for connecting to Ms access database

Hi:

I am new to VB.NET. Can you please tell me as to where this code needs to be typed for acquiring database connectivity?

If you reply ASAP, it will be of great help to me.

Thanks,
Kavitha.









Click to Expand / Collapse  Quote originally posted by SethR ...
try something like this......

Private currpath As String = System.Environment.CurrentDirectory
Private connService As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source= " & currpath & "\ServiceCalls.mdb")
Public daCustomers As New System.Data.OleDb.OleDbDataAdapter("Select * from Customers", connService)
Public daCalls As New System.Data.OleDb.OleDbDataAdapter("Select * from Calls ORDER BY CustomerID", connService)
Private daCallStatus As New System.Data.OleDb.OleDbDataAdapter("Select * from Status", connService)
Private cbCustomers As New System.Data.OleDb.OleDbCommandBuilder(daCustomers)
Private cbCalls As New System.Data.OleDb.OleDb
Reputation Points: 10
Solved Threads: 0
Junior Poster
kavithabhaskar is offline Offline
123 posts
since Jun 2008
Jun 17th, 2008
0

Re: I need help for connecting to Ms access database

Folks:

I am new to VB.Et. Can you please tell me as to where the code for database connectivity needs to be typed?

Thanks,
Kavitha.
Reputation Points: 10
Solved Threads: 0
Junior Poster
kavithabhaskar is offline Offline
123 posts
since Jun 2008
Jun 17th, 2008
0

Re: I need help for connecting to Ms access database

Hi:

I missed to see that the code needs to be typed in the Form Load window. Thanks Mojal. But I hope to keep in touch with you folks to discuss more about VB.NET and Access.

Thanks,
Kavitha.
Reputation Points: 10
Solved Threads: 0
Junior Poster
kavithabhaskar is offline Offline
123 posts
since Jun 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Form x Show on button click
Next Thread in VB.NET Forum Timeline: Crystal report doesnt work there in target pc!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC