Help with data grid

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kimberley Wiggins

    Help with data grid



    Can someone please help me? I am still learning vb so this is fairly
    new.

    I have been chasing this problem for 3 days now and I think that I am
    ready to give up. Does anyone know how to make my data grid display on
    a tab control? I have a tab control with 2 tabs on it, one for the
    data grid and the other for comments. I have tried everything. Where
    do I add the code to say display the data grid on this tab? I have the
    code and everything working to fill the data adapter and fill the data
    grid from the table but I don't know how to make it display on the tab
    control. This is driving me crazy, help...thanks

    this is my code for the data adapter:

    Dim strOTRConnectio n As String = "Provider=Micro soft.Jet.OLEDB. 4.0;
    Data Source= C:\otr.mdb"
    Dim strSQLEpisode As String
    Dim dtEpisode As New DataTable
    Dim dgEpisodes As New DataGrid

    dtEpisode.Clear ()
    strSQLEpisode = "SELECT * " & _
    "FROM Episode WHERE showcode = '" & Me.txtCode.Text & "' "
    Dim dataAdapter As New OleDb.OleDbData Adapter (strSQLEpisode,
    strOTRConnectio n)
    dataAdapter.Fil l(dtEpisode)
    dataAdapter.Dis pose()
    Me.dgEpisodes.D ataSource = dtEpisode


    As you can see, I handled everything in code so I did not build a
    dataset or used any tools. Just added everything to connect the data
    adapter in code.
    Thanks

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
  • Ken Tucker [MVP]

    #2
    Re: Help with data grid

    Hi,

    Are you sure you are getting any data into the datatable ?
    Debug.Writeline (dtEpisode.Rows .Count) will tell you how many rows are being
    returned.

    Ken
    ------------
    "Kimberley Wiggins" <kimwiggins@gre enwaymedical.co m> wrote in message
    news:%23y8xz4N$ DHA.624@TK2MSFT NGP11.phx.gbl.. .[color=blue]
    >
    >
    > Can someone please help me? I am still learning vb so this is fairly
    > new.
    >
    > I have been chasing this problem for 3 days now and I think that I am
    > ready to give up. Does anyone know how to make my data grid display on
    > a tab control? I have a tab control with 2 tabs on it, one for the
    > data grid and the other for comments. I have tried everything. Where
    > do I add the code to say display the data grid on this tab? I have the
    > code and everything working to fill the data adapter and fill the data
    > grid from the table but I don't know how to make it display on the tab
    > control. This is driving me crazy, help...thanks
    >
    > this is my code for the data adapter:
    >
    > Dim strOTRConnectio n As String = "Provider=Micro soft.Jet.OLEDB. 4.0;
    > Data Source= C:\otr.mdb"
    > Dim strSQLEpisode As String
    > Dim dtEpisode As New DataTable
    > Dim dgEpisodes As New DataGrid
    >
    > dtEpisode.Clear ()
    > strSQLEpisode = "SELECT * " & _
    > "FROM Episode WHERE showcode = '" & Me.txtCode.Text & "' "
    > Dim dataAdapter As New OleDb.OleDbData Adapter (strSQLEpisode,
    > strOTRConnectio n)
    > dataAdapter.Fil l(dtEpisode)
    > dataAdapter.Dis pose()
    > Me.dgEpisodes.D ataSource = dtEpisode
    >
    >
    > As you can see, I handled everything in code so I did not build a
    > dataset or used any tools. Just added everything to connect the data
    > adapter in code.
    > Thanks
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it![/color]


    Comment

    • Kimberley Wiggins

      #3
      Re: Help with data grid


      Yes I did try that and it does show that I am getting the correct rows
      into the datatable.


      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      • Cor

        #4
        Re: Help with data grid

        Hi Kimberly,

        It is strange becaus I tested your code (with another database) and it
        showed a datagrid .

        But I had nothing to add to Kens question, because mine would have been the
        same.

        But now my next question, is the datagrid showed (empty)?

        Cor[color=blue]
        > Yes I did try that and it does show that I am getting the correct rows
        > into the datatable.[/color]


        Comment

        • Kimberley Wiggins

          #5
          Re: Help with data grid

          Yes, I finally got the datagrid to display but it is displaying empty.
          I would think that it would just display by the code that is in the
          leading tables records but I guess not. I had it to fill the data
          adapter and it is pointing to the correct table. Do you know what could
          be wrong?
          Thanks

          *** Sent via Developersdex http://www.developersdex.com ***
          Don't just participate in USENET...get rewarded for it!

          Comment

          • Cor

            #6
            Re: Help with data grid

            Hi Kimberley,

            You say finaly, you are sure it is the same datagrid?
            (The same name dgEpisodes)

            Cor


            Comment

            • Kimberley Wiggins

              #7
              Re: Help with data grid

              Yes you were right, I was looking at the wrong grid. It is not pulling
              back any records. It is something in my select statement. When I try
              this:

              strSQLEpisode = "SELECT * from episode"

              it pulls back all 9024 records. But when I try this:

              strSQLEpisode = "SELECT * from episode" & _
              "FROM Episode WHERE showcode = '" & Me.txtCode.Text & "' "

              it pulls back 0. Can you see anything wrong with this statment? The
              text box that it is getting the showcode column from is populating is
              there is no reason why it should not drive off of that.

              *** Sent via Developersdex http://www.developersdex.com ***
              Don't just participate in USENET...get rewarded for it!

              Comment

              • Ken Tucker [MVP]

                #8
                Re: Help with data grid

                Hi,

                Try this.

                strSQLEpisode = "SELECT * from episode" & _
                "FROM Episode WHERE showcode LIKE '" & Me.txtCode.Text & "%' "

                Ken
                ------------------
                "Kimberley Wiggins" <kimwiggins@gre enwaymedical.co m> wrote in message
                news:%23aiTAMW$ DHA.1456@TK2MSF TNGP09.phx.gbl. ..[color=blue]
                > Yes you were right, I was looking at the wrong grid. It is not pulling
                > back any records. It is something in my select statement. When I try
                > this:
                >
                > strSQLEpisode = "SELECT * from episode"
                >
                > it pulls back all 9024 records. But when I try this:
                >
                > strSQLEpisode = "SELECT * from episode" & _
                > "FROM Episode WHERE showcode = '" & Me.txtCode.Text & "' "
                >
                > it pulls back 0. Can you see anything wrong with this statment? The
                > text box that it is getting the showcode column from is populating is
                > there is no reason why it should not drive off of that.
                >
                > *** Sent via Developersdex http://www.developersdex.com ***
                > Don't just participate in USENET...get rewarded for it![/color]


                Comment

                • Cor

                  #9
                  Re: Help with data grid

                  Kimberley,

                  No I see nothing.


                  strSQLEpisode = "SELECT * from episode" & _[color=blue]
                  > "FROM Episode WHERE showcode = '" & Trim(Me.txtCode .Text) & "' "[/color]

                  But in my opinion that cannot be the error.

                  You are shure you fill in a good value?

                  Cor


                  Comment

                  • Kimberley Wiggins

                    #10
                    Re: Help with data grid


                    I found what the problem was. The text field name that is driving what
                    will display in the data grid keep having a record that I entered
                    through my add code. I now need to figure out why that is the record it
                    is always going back to when I start the program instead of back to the
                    beginning of the file. Thanks


                    *** Sent via Developersdex http://www.developersdex.com ***
                    Don't just participate in USENET...get rewarded for it!

                    Comment

                    • CJ Taylor

                      #11
                      Re: Help with data grid


                      "Ken Tucker [MVP]" <vb2ae@bellsout h.net> wrote in message
                      news:%23NbqtPW$ DHA.1732@TK2MSF TNGP12.phx.gbl. ..[color=blue]
                      > Hi,
                      >
                      > Try this.
                      >
                      > strSQLEpisode = "SELECT * from episode" & _
                      > "FROM Episode WHERE showcode LIKE '" & Me.txtCode.Text & "%' "
                      >[/color]

                      ^^ Perhaps a space after the episode or before the from would help?

                      -CJ
                      [color=blue]
                      > Ken
                      > ------------------
                      > "Kimberley Wiggins" <kimwiggins@gre enwaymedical.co m> wrote in message
                      > news:%23aiTAMW$ DHA.1456@TK2MSF TNGP09.phx.gbl. ..[color=green]
                      > > Yes you were right, I was looking at the wrong grid. It is not pulling
                      > > back any records. It is something in my select statement. When I try
                      > > this:
                      > >
                      > > strSQLEpisode = "SELECT * from episode"
                      > >
                      > > it pulls back all 9024 records. But when I try this:
                      > >
                      > > strSQLEpisode = "SELECT * from episode" & _
                      > > "FROM Episode WHERE showcode = '" & Me.txtCode.Text & "' "
                      > >
                      > > it pulls back 0. Can you see anything wrong with this statment? The
                      > > text box that it is getting the showcode column from is populating is
                      > > there is no reason why it should not drive off of that.
                      > >
                      > > *** Sent via Developersdex http://www.developersdex.com ***
                      > > Don't just participate in USENET...get rewarded for it![/color]
                      >
                      >[/color]


                      Comment

                      • meh

                        #12
                        Re: Help with data grid

                        Hi all;

                        Sorry if I've missed something....I' m coming into this late.....but... .

                        Sould I assume that episode and Episode are 2 different tables in this
                        database????

                        meh

                        "Cor" <non@non.com> wrote in message
                        news:eU73SSW$DH A.1212@TK2MSFTN GP12.phx.gbl...[color=blue]
                        > Kimberley,
                        >
                        > No I see nothing.
                        >
                        >
                        > strSQLEpisode = "SELECT * from episode" & _[color=green]
                        > > "FROM Episode WHERE showcode = '" & Trim(Me.txtCode .Text) & "' "[/color]
                        >
                        > But in my opinion that cannot be the error.
                        >
                        > You are shure you fill in a good value?
                        >
                        > Cor
                        >
                        >[/color]


                        Comment

                        • Ken Tucker [MVP]

                          #13
                          Re: Help with data grid

                          Good eye

                          Ken
                          ----------
                          "CJ Taylor" <nospam@blowgoa ts.com> wrote in message
                          news:103v9jdj15 asced@corp.supe rnews.com...[color=blue]
                          >
                          > "Ken Tucker [MVP]" <vb2ae@bellsout h.net> wrote in message
                          > news:%23NbqtPW$ DHA.1732@TK2MSF TNGP12.phx.gbl. ..[color=green]
                          > > Hi,
                          > >
                          > > Try this.
                          > >
                          > > strSQLEpisode = "SELECT * from episode" & _
                          > > "FROM Episode WHERE showcode LIKE '" & Me.txtCode.Text & "%' "
                          > >[/color]
                          >
                          > ^^ Perhaps a space after the episode or before the from would help?
                          >
                          > -CJ
                          >[color=green]
                          > > Ken
                          > > ------------------
                          > > "Kimberley Wiggins" <kimwiggins@gre enwaymedical.co m> wrote in message
                          > > news:%23aiTAMW$ DHA.1456@TK2MSF TNGP09.phx.gbl. ..[color=darkred]
                          > > > Yes you were right, I was looking at the wrong grid. It is not[/color][/color][/color]
                          pulling[color=blue][color=green][color=darkred]
                          > > > back any records. It is something in my select statement. When I try
                          > > > this:
                          > > >
                          > > > strSQLEpisode = "SELECT * from episode"
                          > > >
                          > > > it pulls back all 9024 records. But when I try this:
                          > > >
                          > > > strSQLEpisode = "SELECT * from episode" & _
                          > > > "FROM Episode WHERE showcode = '" & Me.txtCode.Text & "' "
                          > > >
                          > > > it pulls back 0. Can you see anything wrong with this statment? The
                          > > > text box that it is getting the showcode column from is populating is
                          > > > there is no reason why it should not drive off of that.
                          > > >
                          > > > *** Sent via Developersdex http://www.developersdex.com ***
                          > > > Don't just participate in USENET...get rewarded for it![/color]
                          > >
                          > >[/color]
                          >
                          >[/color]


                          Comment

                          Working...