Home All Groups Group Topic Archive Search About

Retrieving info out of a MDB

Author
10 Dec 2006 1:01 AM
John
After reading the tutorial from http://www.startvbdotnet.com/ado/msaccess.aspx I wrote this code in an attempt to get information from my MDB file called FillMe. The only table in that Access file is called MainTable;

Imports System.Data.OleDb

Public Class Form2
Inherits System.Windows.Forms.Form

Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader

'WINDOWS GENERATED

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    OleDbDataAdapter1.Fill(DataSet11)
End Sub
Private Sub exitbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitbutton.Click
    Me.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Try
    cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Documents and Settings\Name\Desktop\FillMe.mdb;")
    'provider to be used when working with access database
    cn.Open()
    cmd = New OleDbCommand("select * from MainTable", cn)
    dr = cmd.ExecuteReader
    While dr.Read()
    TextBox1.Text = dr(0)
    TextBox2.Text = dr(1)
    TextBox3.Text = dr(2)
    'loading data into TextBoxes by column index
    End While
    Catch
    End Try
    dr.Close()
    cn.Close()
End Sub
End Class

Is filling the data set when the form loads neccisary? How would I link the Data adapters and data sets I created to this form?

Author
9 Dec 2006 11:24 PM
Scott M.
"John" <some***@microsoft.com> wrote in message news:jkGeh.57$1x6.49@newsfe09.lga...
  After reading the tutorial from http://www.startvbdotnet.com/ado/msaccess.aspx I wrote this code in an attempt to get information from my MDB file called FillMe. The only table in that Access file is called MainTable;

  Imports System.Data.OleDb

  Public Class Form2
  Inherits System.Windows.Forms.Form

  Dim cn As OleDbConnection
  Dim cmd As OleDbCommand
  Dim dr As OleDbDataReader

  'WINDOWS GENERATED

  Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      OleDbDataAdapter1.Fill(DataSet11)
  End Sub
  Private Sub exitbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitbutton.Click
      Me.Close()
  End Sub
  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      Try
      cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Documents and Settings\Name\Desktop\FillMe.mdb;")
      'provider to be used when working with access database
      cn.Open()
      cmd = New OleDbCommand("select * from MainTable", cn)
      dr = cmd.ExecuteReader
      While dr.Read()
      TextBox1.Text = dr(0)
      TextBox2.Text = dr(1)
      TextBox3.Text = dr(2)
      'loading data into TextBoxes by column index
      End While
      Catch
      End Try
      dr.Close()
      cn.Close()
  End Sub
  End Class

  Is filling the data set when the form loads neccisary?

      You've got to fill it sometime, so why not Page_Load?

  How would I link the Data adapters and data sets I created to this form?

      OleDbDataAdapter1.Fill(DataSet11)
Author
10 Dec 2006 3:31 AM
John
When I click on the button, nothing happens, I dont know what is wrong
  "Scott M." <s-mar@nospam.nospam> wrote in message news:e1O24j%23GHHA.3616@TK2MSFTNGP02.phx.gbl...

    "John" <some***@microsoft.com> wrote in message news:jkGeh.57$1x6.49@newsfe09.lga...
    After reading the tutorial from http://www.startvbdotnet.com/ado/msaccess.aspx I wrote this code in an attempt to get information from my MDB file called FillMe. The only table in that Access file is called MainTable;

    Imports System.Data.OleDb

    Public Class Form2
    Inherits System.Windows.Forms.Form

    Dim cn As OleDbConnection
    Dim cmd As OleDbCommand
    Dim dr As OleDbDataReader

    'WINDOWS GENERATED

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        OleDbDataAdapter1.Fill(DataSet11)
    End Sub
    Private Sub exitbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitbutton.Click
        Me.Close()
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
        cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Documents and Settings\Name\Desktop\FillMe.mdb;")
        'provider to be used when working with access database
        cn.Open()
        cmd = New OleDbCommand("select * from MainTable", cn)
        dr = cmd.ExecuteReader
        While dr.Read()
        TextBox1.Text = dr(0)
        TextBox2.Text = dr(1)
        TextBox3.Text = dr(2)
        'loading data into TextBoxes by column index
        End While
        Catch
        End Try
        dr.Close()
        cn.Close()
    End Sub
    End Class

    Is filling the data set when the form loads neccisary?

        You've got to fill it sometime, so why not Page_Load?

    How would I link the Data adapters and data sets I created to this form?

        OleDbDataAdapter1.Fill(DataSet11)
Author
10 Dec 2006 5:25 AM
RobinS
If you put a breakpoint in the code in the Button1_Click routine,
does it stop there? Or put a debug.writeline statement or something?
To tell you if it ever gets there?

Is this .Net 2003 or .Net 2005?
Robin S.
-------------
  "John" <some***@microsoft.com> wrote in message news:nxIeh.79$Vq.39@newsfe12.lga...
  When I click on the button, nothing happens, I dont know what is wrong
    "Scott M." <s-mar@nospam.nospam> wrote in message news:e1O24j%23GHHA.3616@TK2MSFTNGP02.phx.gbl...

      "John" <some***@microsoft.com> wrote in message news:jkGeh.57$1x6.49@newsfe09.lga...
      After reading the tutorial from http://www.startvbdotnet.com/ado/msaccess.aspx I wrote this code in an attempt to get information from my MDB file called FillMe. The only table in that Access file is called MainTable;

      Imports System.Data.OleDb

      Public Class Form2
      Inherits System.Windows.Forms.Form

      Dim cn As OleDbConnection
      Dim cmd As OleDbCommand
      Dim dr As OleDbDataReader

      'WINDOWS GENERATED

      Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
          OleDbDataAdapter1.Fill(DataSet11)
      End Sub
      Private Sub exitbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitbutton.Click
          Me.Close()
      End Sub
      Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
          Try
          cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Documents and Settings\Name\Desktop\FillMe.mdb;")
          'provider to be used when working with access database
          cn.Open()
          cmd = New OleDbCommand("select * from MainTable", cn)
          dr = cmd.ExecuteReader
          While dr.Read()
          TextBox1.Text = dr(0)
          TextBox2.Text = dr(1)
          TextBox3.Text = dr(2)
          'loading data into TextBoxes by column index
          End While
          Catch
          End Try
          dr.Close()
          cn.Close()
      End Sub
      End Class

      Is filling the data set when the form loads neccisary?

          You've got to fill it sometime, so why not Page_Load?

      How would I link the Data adapters and data sets I created to this form?

          OleDbDataAdapter1.Fill(DataSet11)
Author
10 Dec 2006 4:32 PM
John
The breakpoints happen within the button1_click routine, but not within;

While dr.Read()

TextBox1.Text = dr(0)

TextBox2.Text = dr(1)

TextBox3.Text = dr(2)

End While

I guess thats why the data is'nt being written, but I dont know how to re-write it to make it work.



  "RobinS" <RobinS@NoSpam.yah.none> wrote in message news:bvKdnYE0hvKrB-bYnZ2dnUVZ_o6gnZ2d@comcast.com...
  If you put a breakpoint in the code in the Button1_Click routine,
  does it stop there? Or put a debug.writeline statement or something?
  To tell you if it ever gets there?

  Is this .Net 2003 or .Net 2005?
  Robin S.
  -------------
    "John" <some***@microsoft.com> wrote in message news:nxIeh.79$Vq.39@newsfe12.lga...
    When I click on the button, nothing happens, I dont know what is wrong
      "Scott M." <s-mar@nospam.nospam> wrote in message news:e1O24j%23GHHA.3616@TK2MSFTNGP02.phx.gbl...

        "John" <some***@microsoft.com> wrote in message news:jkGeh.57$1x6.49@newsfe09.lga...
        After reading the tutorial from http://www.startvbdotnet.com/ado/msaccess.aspx I wrote this code in an attempt to get information from my MDB file called FillMe. The only table in that Access file is called MainTable;

        Imports System.Data.OleDb

        Public Class Form2
        Inherits System.Windows.Forms.Form

        Dim cn As OleDbConnection
        Dim cmd As OleDbCommand
        Dim dr As OleDbDataReader

        'WINDOWS GENERATED

        Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            OleDbDataAdapter1.Fill(DataSet11)
        End Sub
        Private Sub exitbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitbutton.Click
            Me.Close()
        End Sub
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Try
            cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Documents and Settings\Name\Desktop\FillMe.mdb;")
            'provider to be used when working with access database
            cn.Open()
            cmd = New OleDbCommand("select * from MainTable", cn)
            dr = cmd.ExecuteReader
            While dr.Read()
            TextBox1.Text = dr(0)
            TextBox2.Text = dr(1)
            TextBox3.Text = dr(2)
            'loading data into TextBoxes by column index
            End While
            Catch
            End Try
            dr.Close()
            cn.Close()
        End Sub
        End Class

        Is filling the data set when the form loads neccisary?

            You've got to fill it sometime, so why not Page_Load?

        How would I link the Data adapters and data sets I created to this form?

            OleDbDataAdapter1.Fill(DataSet11)
Author
10 Dec 2006 4:29 PM
RobinS
What if you try just doing *one* read and filling the textboxes,
rather than looping through the data reader?

Robin S.
------------------------
  "John" <some***@microsoft.com> wrote in message news:9ZTeh.115$Vq.108@newsfe12.lga...
  The breakpoints happen within the button1_click routine, but not within;

  While dr.Read()

  TextBox1.Text = dr(0)

  TextBox2.Text = dr(1)

  TextBox3.Text = dr(2)

  End While

  I guess thats why the data is'nt being written, but I dont know how to re-write it to make it work.



    "RobinS" <RobinS@NoSpam.yah.none> wrote in message news:bvKdnYE0hvKrB-bYnZ2dnUVZ_o6gnZ2d@comcast.com...
    If you put a breakpoint in the code in the Button1_Click routine,
    does it stop there? Or put a debug.writeline statement or something?
    To tell you if it ever gets there?

    Is this .Net 2003 or .Net 2005?
    Robin S.
    -------------
      "John" <some***@microsoft.com> wrote in message news:nxIeh.79$Vq.39@newsfe12.lga...
      When I click on the button, nothing happens, I dont know what is wrong
        "Scott M." <s-mar@nospam.nospam> wrote in message news:e1O24j%23GHHA.3616@TK2MSFTNGP02.phx.gbl...

          "John" <some***@microsoft.com> wrote in message news:jkGeh.57$1x6.49@newsfe09.lga...
          After reading the tutorial from http://www.startvbdotnet.com/ado/msaccess.aspx I wrote this code in an attempt to get information from my MDB file called FillMe. The only table in that Access file is called MainTable;

          Imports System.Data.OleDb

          Public Class Form2
          Inherits System.Windows.Forms.Form

          Dim cn As OleDbConnection
          Dim cmd As OleDbCommand
          Dim dr As OleDbDataReader

          'WINDOWS GENERATED

          Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
              OleDbDataAdapter1.Fill(DataSet11)
          End Sub
          Private Sub exitbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitbutton.Click
              Me.Close()
          End Sub
          Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
              Try
              cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Documents and Settings\Name\Desktop\FillMe.mdb;")
              'provider to be used when working with access database
              cn.Open()
              cmd = New OleDbCommand("select * from MainTable", cn)
              dr = cmd.ExecuteReader
              While dr.Read()
              TextBox1.Text = dr(0)
              TextBox2.Text = dr(1)
              TextBox3.Text = dr(2)
              'loading data into TextBoxes by column index
              End While
              Catch
              End Try
              dr.Close()
              cn.Close()
          End Sub
          End Class

          Is filling the data set when the form loads neccisary?

              You've got to fill it sometime, so why not Page_Load?

          How would I link the Data adapters and data sets I created to this form?

              OleDbDataAdapter1.Fill(DataSet11)
Author
10 Dec 2006 5:39 PM
Cor Ligthert [MVP]
John,

Wrote a complete solution in the other newsgroup you have posted too.

Cor
  "John" <some***@microsoft.com> schreef in bericht news:9ZTeh.115$Vq.108@newsfe12.lga...
  The breakpoints happen within the button1_click routine, but not within;

  While dr.Read()

  TextBox1.Text = dr(0)

  TextBox2.Text = dr(1)

  TextBox3.Text = dr(2)

  End While

  I guess thats why the data is'nt being written, but I dont know how to re-write it to make it work.



    "RobinS" <RobinS@NoSpam.yah.none> wrote in message news:bvKdnYE0hvKrB-bYnZ2dnUVZ_o6gnZ2d@comcast.com...
    If you put a breakpoint in the code in the Button1_Click routine,
    does it stop there? Or put a debug.writeline statement or something?
    To tell you if it ever gets there?

    Is this .Net 2003 or .Net 2005?
    Robin S.
    -------------
      "John" <some***@microsoft.com> wrote in message news:nxIeh.79$Vq.39@newsfe12.lga...
      When I click on the button, nothing happens, I dont know what is wrong
        "Scott M." <s-mar@nospam.nospam> wrote in message news:e1O24j%23GHHA.3616@TK2MSFTNGP02.phx.gbl...

          "John" <some***@microsoft.com> wrote in message news:jkGeh.57$1x6.49@newsfe09.lga...
          After reading the tutorial from http://www.startvbdotnet.com/ado/msaccess.aspx I wrote this code in an attempt to get information from my MDB file called FillMe. The only table in that Access file is called MainTable;

          Imports System.Data.OleDb

          Public Class Form2
          Inherits System.Windows.Forms.Form

          Dim cn As OleDbConnection
          Dim cmd As OleDbCommand
          Dim dr As OleDbDataReader

          'WINDOWS GENERATED

          Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
              OleDbDataAdapter1.Fill(DataSet11)
          End Sub
          Private Sub exitbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitbutton.Click
              Me.Close()
          End Sub
          Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
              Try
              cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Documents and Settings\Name\Desktop\FillMe.mdb;")
              'provider to be used when working with access database
              cn.Open()
              cmd = New OleDbCommand("select * from MainTable", cn)
              dr = cmd.ExecuteReader
              While dr.Read()
              TextBox1.Text = dr(0)
              TextBox2.Text = dr(1)
              TextBox3.Text = dr(2)
              'loading data into TextBoxes by column index
              End While
              Catch
              End Try
              dr.Close()
              cn.Close()
          End Sub
          End Class

          Is filling the data set when the form loads neccisary?

              You've got to fill it sometime, so why not Page_Load?

          How would I link the Data adapters and data sets I created to this form?

              OleDbDataAdapter1.Fill(DataSet11)
Author
12 Dec 2006 1:40 PM
Webuser
thank you
  "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:et%23yrHIHHHA.4712@TK2MSFTNGP04.phx.gbl...
  John,

  Wrote a complete solution in the other newsgroup you have posted too.

  Cor
    "John" <some***@microsoft.com> schreef in bericht news:9ZTeh.115$Vq.108@newsfe12.lga...
    The breakpoints happen within the button1_click routine, but not within;

    While dr.Read()

    TextBox1.Text = dr(0)

    TextBox2.Text = dr(1)

    TextBox3.Text = dr(2)

    End While

    I guess thats why the data is'nt being written, but I dont know how to re-write it to make it work.



      "RobinS" <RobinS@NoSpam.yah.none> wrote in message news:bvKdnYE0hvKrB-bYnZ2dnUVZ_o6gnZ2d@comcast.com...
      If you put a breakpoint in the code in the Button1_Click routine,
      does it stop there? Or put a debug.writeline statement or something?
      To tell you if it ever gets there?

      Is this .Net 2003 or .Net 2005?
      Robin S.
      -------------
        "John" <some***@microsoft.com> wrote in message news:nxIeh.79$Vq.39@newsfe12.lga...
        When I click on the button, nothing happens, I dont know what is wrong
          "Scott M." <s-mar@nospam.nospam> wrote in message news:e1O24j%23GHHA.3616@TK2MSFTNGP02.phx.gbl...

            "John" <some***@microsoft.com> wrote in message news:jkGeh.57$1x6.49@newsfe09.lga...
            After reading the tutorial from http://www.startvbdotnet.com/ado/msaccess.aspx I wrote this code in an attempt to get information from my MDB file called FillMe. The only table in that Access file is called MainTable;

            Imports System.Data.OleDb

            Public Class Form2
            Inherits System.Windows.Forms.Form

            Dim cn As OleDbConnection
            Dim cmd As OleDbCommand
            Dim dr As OleDbDataReader

            'WINDOWS GENERATED

            Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                OleDbDataAdapter1.Fill(DataSet11)
            End Sub
            Private Sub exitbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitbutton.Click
                Me.Close()
            End Sub
            Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
                Try
                cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Documents and Settings\Name\Desktop\FillMe.mdb;")
                'provider to be used when working with access database
                cn.Open()
                cmd = New OleDbCommand("select * from MainTable", cn)
                dr = cmd.ExecuteReader
                While dr.Read()
                TextBox1.Text = dr(0)
                TextBox2.Text = dr(1)
                TextBox3.Text = dr(2)
                'loading data into TextBoxes by column index
                End While
                Catch
                End Try
                dr.Close()
                cn.Close()
            End Sub
            End Class

            Is filling the data set when the form loads neccisary?

                You've got to fill it sometime, so why not Page_Load?

            How would I link the Data adapters and data sets I created to this form?

                OleDbDataAdapter1.Fill(DataSet11)