[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.
Re: sql command help needed
Why wouldn't this work?
Code:
lblName.Text = myDataset.Tables(0).Rows(e).Item("names")
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
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
Re: sql command help needed