Ask a Question related to ASP.NET General, Design and Development.
-
KathyB #1
dropdown lists - query parameter error
Hi,
I'm using the following for 2 dropdown boxes in asp.net. The first is
the basis for the contents of the second. First works fine, then on
its selectedindexchanged event I get "No value given for one or more
required parameters" error.
I've had it worked ok before using datasets, but can't get it to work
with datareader.
Any hints welcome. Thanks, Kathy
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
Dim Conn1 As OleDbConnection
Dim Rdr1 As OleDbDataReader
Dim Cmd1 As OleDbCommand
Dim strSQL As String
Conn1 = New OleDbConnection(strConn)
strSQL = "SELECT DISTINCT Customer FROM tblCustomers"
Cmd1 = New OleDbCommand(strSQL, Conn1)
Conn1.Open()
Rdr1 = Cmd1.ExecuteReader()
cboCust.DataSource = Rdr1
cboCust.DataBind()
cboCust.Items.Insert(0, "Select Customer")
cboCust.SelectedIndex = 0
Rdr1.Close()
Conn1.Close()
End If
End Sub
Private Sub cboCust_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
cboCust.SelectedIndexChanged
'If Not IsPostBack Then
Dim Conn2 As New OleDbConnection()
Dim Rdr2 As OleDbDataReader
Dim Cmd2 As OleDbCommand
Dim strSQL2 As String
Conn2 = New OleDbConnection(strConn)
strSQL2 = "SELECT Assy FROM tblAssy WHERE ([Customer] =
@customer)"
Dim prmCustomer As OleDbParameter = New
OleDbParameter("@customer", OleDbType.VarChar, 50)
Conn2.Open()
Cmd2 = New OleDbCommand(strSQL2, Conn2)
prmCustomer.Value = cboCust.SelectedItem.Value
Rdr2 = Cmd2.ExecuteReader()
cboAssy.DataSource = Rdr2
cboAssy.DataBind()
cboAssy.Items.Insert(0, "Select Assembly")
cboCust.SelectedIndex = 0
Rdr2.Close()
Conn2.Close()
'End If
End Sub
KathyB Guest
-
working with dropdown lists
I appologize for what is probably a very novice question. I am creating dropdown lists for an online store. The purpose of the list is to choose a... -
Dropdown lists navigation
Hi Sven, Unfortunately I never got this to work, because I went round in circles for a while and ran out of time. However, I did find a way round,... -
Dropdown lists navigation2
Hi everybody, I'm trying to make Dropdown list in my presentation according to previous topic about Dropdown menu but without the success. The goal... -
How to question: Added new values to dropdown lists & database
This is my attempt to rephrase a question I asked earlier that got no response. I suspect it was my poor/unplanned wording. Here is another... -
Sorting data in Listbox/Dropdown lists
hi, i have loaded the listbox with the data from a database using dataset. i am finding difficulty in sorting the data. i am not able to find a... -
Kevin Spencer #2
Re: dropdown lists - query parameter error
....and the line that threw the error is...?
HTH,
Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
[url]http://www.takempis.com[/url]
Big things are made up of
lots of Little things.
"KathyB" <KathyBurke40@attbi.com> wrote in message
news:75e8d381.0306261033.14322196@posting.google.c om...> Hi,
>
> I'm using the following for 2 dropdown boxes in asp.net. The first is
> the basis for the contents of the second. First works fine, then on
> its selectedindexchanged event I get "No value given for one or more
> required parameters" error.
>
> I've had it worked ok before using datasets, but can't get it to work
> with datareader.
>
> Any hints welcome. Thanks, Kathy
>
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> 'Put user code to initialize the page here
>
> If Not IsPostBack Then
>
> Dim Conn1 As OleDbConnection
> Dim Rdr1 As OleDbDataReader
> Dim Cmd1 As OleDbCommand
> Dim strSQL As String
>
> Conn1 = New OleDbConnection(strConn)
>
> strSQL = "SELECT DISTINCT Customer FROM tblCustomers"
> Cmd1 = New OleDbCommand(strSQL, Conn1)
> Conn1.Open()
> Rdr1 = Cmd1.ExecuteReader()
> cboCust.DataSource = Rdr1
> cboCust.DataBind()
> cboCust.Items.Insert(0, "Select Customer")
> cboCust.SelectedIndex = 0
> Rdr1.Close()
>
> Conn1.Close()
>
> End If
> End Sub
>
> Private Sub cboCust_SelectedIndexChanged(ByVal sender As
> System.Object, ByVal e As System.EventArgs) Handles
> cboCust.SelectedIndexChanged
>
> 'If Not IsPostBack Then
>
> Dim Conn2 As New OleDbConnection()
> Dim Rdr2 As OleDbDataReader
> Dim Cmd2 As OleDbCommand
> Dim strSQL2 As String
>
> Conn2 = New OleDbConnection(strConn)
>
> strSQL2 = "SELECT Assy FROM tblAssy WHERE ([Customer] =
> @customer)"
> Dim prmCustomer As OleDbParameter = New
> OleDbParameter("@customer", OleDbType.VarChar, 50)
> Conn2.Open()
> Cmd2 = New OleDbCommand(strSQL2, Conn2)
> prmCustomer.Value = cboCust.SelectedItem.Value
> Rdr2 = Cmd2.ExecuteReader()
> cboAssy.DataSource = Rdr2
> cboAssy.DataBind()
> cboAssy.Items.Insert(0, "Select Assembly")
> cboCust.SelectedIndex = 0
> Rdr2.Close()
> Conn2.Close()
>
> 'End If
> End Sub
Kevin Spencer Guest



Reply With Quote

