Results 1 to 5 of 5

Thread: [RESOLVED] sql command help needed

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2008
    Posts
    778

    Resolved [RESOLVED] sql command help needed

    I got this code to get alll the notes loaded
    Code:
    Private Sub Load_History()
            Dim myCnt As Integer
            Dim myStr As String
            Dim myDataset As New DataSet
            Dim i As Integer = 10
            Dim e As Integer = -1
    
    
            myStr = "select owner,names from orders"
            Dim sqldaHistory As New SqlDataAdapter(myStr, nwindconn)
    
            sqldaHistory.Fill(myDataset, "orders")
    
            myCnt = myDataset.Tables(0).Rows.Count
    
            Do While i > 0
    
                i = i - 1
                e = e + 1
    
                pnltable.RowStyles.Add(New RowStyle(SizeType.Absolute, 100))
    
                Dim lblName As New Label
                'lblName.Text = myDataset.Tables(0).Rows(e).Item("owner")
    
                Dim listEvent As New ListBox
                listEvent.Size = New Size(100, 20)
                listEvent.Items.Add("Update")
    
                Dim lblNote As New Label
                lblNote.Text = myDataset.Tables(0).Rows(e).Item("notes")
                lblNote.Size = New Size(300, 100)
    
                pnltable.Controls.Add(lblName)
                pnltable.Controls.Add(listEvent)
                pnltable.Controls.Add(lblNote)
    
            Loop
    
        End Sub
    It displays 10 latest notes for me, but I also want it to display the name from the same row as notes.

  2. #2
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: sql command help needed

    Why wouldn't this work?
    Code:
    lblName.Text = myDataset.Tables(0).Rows(e).Item("names")
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2008
    Posts
    778

    Re: sql command help needed

    it says that the column does not belong to the table "orders" when I know it's there.

    I think myStr = "select notes from orders" may not be suitable for multiple columns. it is only good to take one of the columns from the DB (owner or notes). So it does work with one of these but not with both

    Thanks

  4. #4
    Hyperactive Member su ki's Avatar
    Join Date
    Oct 2007
    Posts
    354

    Re: sql command help needed

    hey MrtforCode
    u may select as many as columns from the table even from multitables too

    just use select * from orders all columns and all records will be returned
    * If my post helped you, please Rate it
    * If your problem is solved please also mark the thread resolved it is there in right top of page under thread tools
    * Why Rating is useful

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2008
    Posts
    778

    Re: sql command help needed

    cheers, resolved

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