Results 1 to 12 of 12

Thread: Microsoft Access

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2007
    Location
    Las Vegas, NV
    Posts
    301

    Microsoft Access

    I'm using Access 2003. How do I get my data grid in my software to display the information contained with an Access file located on my desktop?

    If anyone has the code string, it would be appreciated...

  2. #2
    Hyperactive Member
    Join Date
    May 2005
    Posts
    334

    Re: Microsoft Access

    I'm not familiar with Access. For SQL Server we import System.Data.SQLClient. For Oracle we import Oracle.DataAccess.Client so I imagine Access does something similar although somebody in another thread said 'just add it to your project'. Build a connection string & create a connection object (SQLConnection for SQL Server) using that string. Finally, open the connection object. Now, you can read the data using either a DataAdapter or a DataReader.

    I'm also not very familiar with DataGridView but I imagine they have a datasource object. I doubt if you can set it directly to the database, usually that requires setting it to either a table or the output of a SQL statement (which is treated like a table if you use a DataAdapter to put it in a DataSet).

    Hopefully this gives you enough 'clues' that you can find what you need in Help. Sorry I can't be more specific but like I said, I don't use either Access or DataGrids.

  3. #3
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,168

    Re: Microsoft Access


  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Microsoft Access

    I've already provided you some links to ADO.NET tutorials in a previous thread, specifically those in my signature. The Start VB.NET site has a section dedicated to Access event. The information you need is already at your disposal.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2007
    Location
    Las Vegas, NV
    Posts
    301

    Re: Microsoft Access

    I've been reading that stuff, but a lot of it seems a little complicated...

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2007
    Location
    Las Vegas, NV
    Posts
    301

    Re: Microsoft Access

    From what I read, here is the code I have to make the database load from the file on my desktop, but I keep getting an error on the "import" tag... it's a syntax error... anyone know how to fix that?

    Code:
         'Imports OleDb namespace
            Imports System.Data.OleDb()
    
            Dim I As Integer = 0
            Dim dteAboutVBDate(10000) As Date
            Dim strAboutVBDesc(10000) As String
            Dim blnAboutVB6(10000) As Boolean
            Dim blnAboutVBNet(10000) As Boolean
            Dim urlAboutVBURL(10000) As String
    
            Dim strAboutVBConn As String = _
      "Provider=Microsoft.Jet.OLEDB.4.0;" _
      & "User ID=Admin;" _
      & "Data Source=C:\Documents and Settings\conflix\Desktop\db2.ldb"

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Microsoft Access

    Namespaces aren't followed by parentheses, nor does that Start VB.NET page suggest that they are. You may also like to check out TechGnome's ADO.NET tutorial from my signature. It is written for SQL Server but all you have to do is change SqlClient to OleDb and everything else is the same. Also see www.connectionstrings.com for the appropriate connection string format if you're unsure.

    Also, why do you have five arrays with 10001 elements each?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2007
    Location
    Las Vegas, NV
    Posts
    301

    Re: Microsoft Access

    i got it from one of your links... i'm trying to understand what i need and don't need... i'm looking at what you just gave me...

    i'm looking at the strings, but everytime i try one, it tells me the first word is an error... how do i fix that?

  9. #9
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Microsoft Access

    I can't tell you how to fix an error if I don't know what it is. I don't know what strings you mean, what word you mean or what the actual error message is. Whenever you get an error show what you did and what the error is. Otherwise we're just guessing.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2007
    Location
    Las Vegas, NV
    Posts
    301

    Re: Microsoft Access

    just the word "driver" shows as a syntax error

    Code:
    Driver={SQL Server};Server=p3swhsql-v01.shr.phx3.secureserver.net;Database=DB_1002583;Uid=stepyourgameup;Pwd=millions;
    If I try this one, the word "Provider" gives me a syntax error

    Code:
    Provider=sqloledb;Data Source=p3swhsql-v01.shr.phx3.secureserver.net;Initial Catalog=DB_1002583;User Id=stepyourgameup;Password=millions
    I've tried replacing the source with my local machine. The database source you see is the one I did on godaddy.

  11. #11
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Microsoft Access

    The first one is for an ODBC connection to SQL Server, not an OLEDB connection to Access. The second is for an OLEDB connection but to SQL Server, not Access.

    Go to www.connectionstrings.com, click on the Access link and get the format for an OleDbConnection. Having said that, you've already got one in you post above because that Start VB.NET example was using an OleDbConnection.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2007
    Location
    Las Vegas, NV
    Posts
    301

    Re: Microsoft Access

    i have SQL server through godaddy. i thought i would try that, but it didn't work...

    i've been reading the database info all day, so far, no progress, but i'm going to keep reading unless anyone can tell me what i'm doing wrong or what i'm missing...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width