Hey i am also facing the same problem.
I have tried this but this is not working.
please help me.

Protected Sub cmbParty_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbParty.SelectedIndexChanged
        Adpt = New SqlDataAdapter("SELECT * FROM PartyMaster where Id = '" & cmbParty.SelectedIndex & "'", myConnection)
        For Each row In ExDs.Tables(0).Rows
        If ExDs.HasErrors Then
            lblMessage.Text = "Error while fetching Data."

Here i need to take the data from exds to text boxes. As when we click on combobox we need to show data according to that party in all text box's.

            txtParty.Text = command("PartyName")
            txtParty.Text = partyName(cmbParty.Items.IndexOf(cmbParty.Text))
        End If

Please help me.
send details ....

Write This Code In Lost_Focus event of ComboBox:(Conn-> Connection object)

DIm RST As New ADODB.RecordSet
Dim sSQL As String

sSQL = "Select * From MyTable Where RollNo = " & Val(Combo1.Text)
RST.Open sSQL, Conn
If Not RSt.EOF Then
txtName.Text = RST("Name")
txtAdd.Text = RST("Addr")
txtAge.Text = RST("Age")
txtName.Text = ""
txtAdd.Text = ""
txtAge.Text = ""
End If
Set RST=Nothing


Hello Raviachhwani.

SqlDataAdapter works in CLOSED Connection. So, while working with sqlDataAdapter,
you don't need to open and close the connection.

Now, here's the solution to your problem. (This is my approach of coding)

First while loading data into your combo box, do this way:


Adpt = New SqlDataAdapter("SELECT id,PartyName FROM PartyMaster", myConnection)
dim Dset as new DataSet
With cmbParty
   .DisplayMember = "PartyName"
   .ValueMember = "id"
   .DataSource = Dset.Tables(0)
End With


Now, when user clicks the value from the comboBox (cmbParty), its corresponding
data should be dispalyed in the textboxes. Right?
This can be done this way.


Adpt = New SqlDataAdapter("SELECT * FROM PartyMaster where 
      Id = " & cmbParty.SelectedValue & "",  myConnection)
dim Dset2 as new DataSet

txtbox1.text =  Dset2.Tables(0).Rows(0)(0)
txtbox2.text =  Dset2.Tables(0).Rows(0)(1)
txtbox3.text =  Dset2.Tables(0).Rows(0)(2)


Ps: I haven't use exceptional Handling in above code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.