I have a edit form that is supposed to load previously saved data from tableA located in DB1. There is a drop down list that is supposed to retrieve the saved data as the selecteditem, but is throwing an error above. The drop down has a SQLdataSource to tableB on DB2, so the population of the selected value is different from the drop down list populated contents (if that makes sense). I did check, and the value that is supposed to appear when the record is retrieved exists in BOTH tables on both DB's. I have seen a lot of others with this error, but I cannot seem to make mine work. Can anyone help?
Here's the ASPX markup for the list:
Code:
 Product Brand Name: <asp:DropDownList ID="product" runat="server" AppendDataBoundItems="True" DataSourceID="SqlDataSource19" DataTextField="Brandname" DataValueField="Brandname" AutoPostBack="true"><asp:ListItem> </asp:ListItem></asp:DropDownList>&nbsp&nbsp
..and here's the VB:
Code:
Protected Sub DropDownList6_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DropDownList6.SelectedIndexChanged
        Dim conn As New SqlConnection("Data Source=azda-sql0;Initial Catalog=ESDForms;User ID=sa;Password=Sql@dm!n")
        Dim cmd As New SqlCommand
        Dim reader As SqlDataReader
        cmd.CommandText = "select * from forma where rptnum = @rptnum"
        cmd.Parameters.Clear()
        cmd.Parameters.Add("@rptnum", SqlDbType.NVarChar).Value = DropDownList6.SelectedValue
        cmd.CommandType = Data.CommandType.Text
        cmd.Connection = conn
        conn.Open()
        reader = cmd.ExecuteReader()
        While reader.Read()
            dt.Text = reader("date")
            inspname.SelectedValue = reader("inspname")
            inspphone.Text = reader("inspphone")
            inspmail.Text = reader("inspmail")
            TextBox28.Text = reader("inspname")
            lastinsp.Text = reader("lastinspdate")
            eform.Text = reader("forme")
            caseno.Text = reader("caseno")
            insptype.SelectedValue = reader("insptype")
            RBL1.SelectedValue = reader("tier")
            RBL7.SelectedValue = reader("grade")
            enddt.Text = reader("enddate")
            sttime.Text = reader("starttime")
            endtime.Text = reader("endtime")
            RBL2.SelectedValue = reader("drift")
            Tank.Text = reader("tanksamp")
            drift.Text = reader("driftcard")
            txt1080.Text = reader("gwpl")
            other.Text = reader("other")
            photos.Text = reader("photo")
            docs.Text = reader("docs")
            DDL2.SelectedValue = reader("pgp")
            DDL3.SelectedValue = reader("aap")
            RBL3.SelectedValue = reader("golf")
            DDL4.SelectedValue = reader("catype")
            DropDownList2.SelectedValue = reader("ca")
            DDL5.SelectedValue = reader("putype")
            DDL6.SelectedValue = reader("pu")
            RBL4.SelectedValue = reader("appprog")
            TextBox25.Text = reader("caname")
            TextBox1.Text = reader("employer")
            TextBox26.Text = reader("handname")
            TextBox2.Text = reader("noatsite")
            TextBox27.Text = reader("puname")
            TextBox3.Text = reader("interviewee")
            TextBox4.Text = reader("inttitle")
            TextBox5.Text = reader("coaddress")
            TextBox6.Text = reader("city")
            TextBox7.Text = reader("state")
            TextBox8.Text = reader("zip")
            TextBox10.Text = reader("phone")
            RBL5.SelectedValue = reader("equipinfo")
            RBL6.SelectedValue = reader("equiptype")
            equiptag.Text = reader("equiptag")
            TextBox11.Text = reader("windspeed")
            direction.SelectedValue = reader("winddir")
            TextBox24.Text = reader("pgpname")
            DropDownList4.SelectedValue = reader("commodity")
            DropDownList5.SelectedValue = reader("pest")
            TextBox15.Text = reader("acres")
            TextBox9.Text = reader("volume")
            TextBox16.Text = reader("applocation")
            TextBox17.Text = reader("appcity")
            TextBox18.Text = reader("appzip")
            county.SelectedValue = reader("county")
            TextBox20.Text = reader("adjacentn")
            TextBox21.Text = reader("adjacents")
            TextBox22.Text = reader("adjacente")
            TextBox23.Text = reader("adjacentw")
            product.SelectedValue = reader("chemapplied")
'more code for other fields
     End While
        reader.Close()
        conn.Close()
        Me.DropDownList6.Enabled = False
    End Sub
Any ideas?