•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 402,366 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,095 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser: Programming Forums
Views: 6350 | Replies: 10
![]() |
•
•
Join Date: Oct 2006
Location: Iran_Tehran
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
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 OLEDB
ystem database=;Jet OLEDB
FP=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
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 OLEDB
ystem database=;Jet OLEDB
FP=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
•
•
Join Date: Apr 2005
Location: Milwaukee, WI
Posts: 156
Reputation:
Rep Power: 4
Solved Threads: 3
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
Andy
Nobody believes the official spokesman, but everybody trusts an unidentified source.
-- Please do not PM me with questions about a thread. If you respond to a thread, then everyone can benefit.
-- Please do not PM me with questions about a thread. If you respond to a thread, then everyone can benefit.
•
•
Join Date: Apr 2005
Location: Milwaukee, WI
Posts: 156
Reputation:
Rep Power: 4
Solved Threads: 3
•
•
•
•
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
Nobody believes the official spokesman, but everybody trusts an unidentified source.
-- Please do not PM me with questions about a thread. If you respond to a thread, then everyone can benefit.
-- Please do not PM me with questions about a thread. If you respond to a thread, then everyone can benefit.
•
•
Join Date: Oct 2005
Posts: 33
Reputation:
Rep Power: 3
Solved Threads: 1
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
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
•
•
Join Date: Jun 2008
Posts: 107
Reputation:
Rep Power: 1
Solved Threads: 0
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
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
•
•
•
•
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 OLEDB
FP=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
•
•
Join Date: Jun 2008
Posts: 107
Reputation:
Rep Power: 1
Solved Threads: 0
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.
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.
•
•
•
•
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
![]() |
•
•
•
•
•
•
•
•
DaniWeb VB.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Writing to an Access Database (Visual Basic 4 / 5 / 6)
- VB: Connect to Access database via ODBC datasource name (Visual Basic 4 / 5 / 6)
- Connecting password protected MS Access database from C# (C#)
- Connecting Access 2000 to a Sybase Database via ODBC (MS Access and FileMaker Pro)
- Registration and Login scripts using VB and Oledbconnection to Access Database (ASP.NET)
- Writing to an Access Database using Java... (Java)
Other Threads in the VB.NET Forum
- Previous Thread: linking database Microsoft Access with VB.NET
- Next Thread: Using PL/SQL in VB.net


Linear Mode