Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET Database and Reporting > DataGrid populated with data from MS Access: How To?


Reply
 
Thread Tools Display Modes
  #1  
Old 05-19-2008, 11:25 PM
mandeline03 mandeline03 is offline
Newcomer
 
Join Date: May 2008
Posts: 1
Default DataGrid Viewing


Edit by moderator:
Split from this thread.
See our Posting Guidelines for our policy on archived threads.


I am confused as to where to place the following code snippet in my code. I put the function above my load event and the same exception still occurs:

An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll

This happens at:

Code:
da.Fill(ds)

Is there another method at creating a dataset to view my data from my databsase?
Any help that you could advise would be greatly appreciated.

Code:
  
  Private Function GetConnectionString(ByVal Database As String) As String
        Dim sConnection As String
        sConnection = "Jet OLEDB:Global Partial Bulk Ops=2;" & _
                      "Jet OLEDB:Registry Path=;" & _
                      "Jet OLEDB:Database Locking Mode=1;" & _
                      "Data Source=""" & Database & """;" & _
                      "Mode=Share Deny None;" & _
                      "Jet OLEDB:Engine Type=5;" & _
                      "Provider=""Microsoft.Jet.OLEDB.4.0"";" & _
                      "Jet OLEDB:System database=;" & _
                      "Jet OLEDB:SFP=False;" & _
                      "persist security info=False;" & _
                      "Extended Properties=;" & _
                      "Jet OLEDB:Compact Without Replica Repair=False;" & _
                      "Jet OLEDB:Encrypt Database=False;" & _
                      "Jet OLEDB:Create System Database=False;" & _
                      "Jet OLEDB:Don't Copy Locale on Compact=False;" & _
                      "User ID=Admin;" & _
                      "Jet OLEDB:Global Bulk Transactions=1"
        Return sConnection
    End Function
Just pass it the name of the database and it will do the rest. If your database
is in the application directory you can call it like this. Otherwise in the whole path to your file
Code:
dim myConnection as New Oledb.OledbConnection myConnection.ConnectionString = GetConnectionString(System.IO.Directory.GetCurrentDirectory() & "\test.mdb")
[/QUOTE]

Last edited by lebb; 05-21-2008 at 11:19 AM. Reason: Split new question to separate thread
Reply With Quote
  #2  
Old 05-20-2008, 04:24 AM
martonx martonx is offline
Centurion
 
Join Date: Jan 2007
Location: Szeged, Hungary
Posts: 129
Default

My advice is using GUI only. You don't need to write any code!
You should add a datasource (there is a wizard, so it is very easy), and drag'n'drop this datasource (in real this is a dataset) to your empty form.
The VB.NET will do for you a new bounded datagridview.

This is the simpliest method!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->