nhaas

I am trying to show to items in a list box, From SQL. I have information loading into the listbox but would like to figure out how to do two.

here is my code:

Me.Cursor = Cursors.WaitCursor ' CHANGE CURSER TO A WAITING CURSOR THEN DO WORK

Dim connectionString = "Data Source=SERVER;Initial Catalog=Tesisdev;Integrated Security=True"

Dim theDataSet As New DataSet()

Dim theSqlCommand As New SqlCommand("Select [BILLINGNUM],[INVOICEDATE] from [OVERAGESINVOICE]", New SqlConnection(connectionString))

Dim theDataAdapter As New SqlDataAdapter(theSqlCommand)

theDataAdapter.Fill(theDataSet)

Me.invoiceBox.DataSource = theDataSet.Tables(0).DefaultView

Me.invoiceBox.ValueMember = "BILLINGNUM"

Me.invoiceBox.DisplayMember = "BILLINGNUM" + "INVOICEDATE"

Me.Cursor = Cursors.Default ' CHANGE BACK TO A NORMAL CURSER BECAUSE WORK IS DONE

thanks for the help




Re: Visual Basic Express Edition showing 2 display members in List box

nhaas

I think what I need is "multiple columns in a listbox"




Re: Visual Basic Express Edition showing 2 display members in List box

spotty

Use a listview or a datagridview control with fullrow select





Re: Visual Basic Express Edition showing 2 display members in List box

nhaas

which would be the best for just displaying two columns I want to be able to select a row so that I can work off of the information.

Thank you.






Re: Visual Basic Express Edition showing 2 display members in List box

stlarmon

I would add a Display Column in the Sql Query

"Select [BILLINGNUM],[INVOICEDATE], [BILLINGNUM] + ' ' + [INVOICEDATE] AS Display from [OVERAGESINVOICE]"

Then set the display member

Me.invoicebox.DisplayMember = "Display"






Re: Visual Basic Express Edition showing 2 display members in List box

spotty

I'd use datagridview as its extemely easy to set the databindings up for your dataset.





Re: Visual Basic Express Edition showing 2 display members in List box

nhaas

Doing this Display Member I get an error that says it cannot convert a varchar to numeric. So I needed to make both the colums the same type. after it worked great, thanks for the info! Never heard of doing that, will need to remember for future.........




Re: Visual Basic Express Edition showing 2 display members in List box

spotty

Or use a cast function within you SQL Statement to turn them into a common type, probably varchar.