J_Kogan
asked on
How to populate list box from stored procedure with one parameter?
I have a stored procedure – “SP_Load_ListBox” and one parameter in this stored procedure- @Param.
This stored procedure select two fields – FieldForDataTextfield – field for data text field of my list box and FieldForDataValueField – field for data value field of my list box.
User must enter the parameter value in the textbox1, click button and list box must be populated from this stored procedure with parameter.
How can I populate my list box from this store procedure with parameter (data text field and data value field of my list box)?
This stored procedure select two fields – FieldForDataTextfield – field for data text field of my list box and FieldForDataValueField – field for data value field of my list box.
User must enter the parameter value in the textbox1, click button and list box must be populated from this stored procedure with parameter.
How can I populate my list box from this store procedure with parameter (data text field and data value field of my list box)?
ASKER
I am sorry, I don't have a wizard, I use VS 2003/VB.NET
Can you give me a code sample? I need to bind listbox with store proc.
Can you give me a code sample? I need to bind listbox with store proc.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much.
It works, but in VS2003 I don’t have AddWithValue method, I put:
cmdListBox.Parameters.Add( New SqlParameter("@POST_CODE", SqlDbType.NVarChar, 4))
cmdListBox.Parameters("@PO ST_CODE"). Value = TextBox1.Text
This code didn’t work:
Dim objDataTable As New DataTable
objSQLDataAdapter.Fill(obj DataTable)
ddl.DataSource = objDataTable
I put:
Dim objDataTable As New DataTable
sqaListBox.Fill(dstListBox , "objDataTable") 'dstListBox-dataset
Dim tbTable As New DataTable
tbTable = dstListBox.Tables(0)
lstAppYear.DataSource = tbTable
All the rest code is OK,
Thank you
It works, but in VS2003 I don’t have AddWithValue method, I put:
cmdListBox.Parameters.Add(
cmdListBox.Parameters("@PO
This code didn’t work:
Dim objDataTable As New DataTable
objSQLDataAdapter.Fill(obj
ddl.DataSource = objDataTable
I put:
Dim objDataTable As New DataTable
sqaListBox.Fill(dstListBox
Dim tbTable As New DataTable
tbTable = dstListBox.Tables(0)
lstAppYear.DataSource = tbTable
All the rest code is OK,
Thank you
the point to remember here is that it will run BEFORE the page loads - which means your user didnt have the chance to enter data yet... and therefore - set a default value (in the same step where you connect to the control) - you can set it to something that wouldnt yield any results if you want the list to be empty before the user selected anything