Professional Web Applications Themes

dropdown lists - query parameter error - ASP.NET General

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 ...

  1. #1

    Default 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

  2. #2

    Default 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" <KathyBurke40attbi.com> wrote in message
    news:75e8d381.0306261033.14322196posting.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

Similar Threads

  1. working with dropdown lists
    By trtouslee in forum Dreamweaver AppDev
    Replies: 0
    Last Post: February 27th, 03:18 AM
  2. Dropdown lists navigation
    By IIJohn webforumsuser@macromedia.com in forum Macromedia Director Basics
    Replies: 2
    Last Post: October 13th, 11:54 PM
  3. Dropdown lists navigation2
    By IIJohn webforumsuser@macromedia.com in forum Macromedia Director Basics
    Replies: 0
    Last Post: September 25th, 10:44 AM
  4. How to question: Added new values to dropdown lists & database
    By Chris Becker in forum ASP.NET General
    Replies: 2
    Last Post: July 3rd, 03:03 AM
  5. Sorting data in Listbox/Dropdown lists
    By Sriram in forum ASP.NET General
    Replies: 2
    Last Post: June 27th, 02:11 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139