Note that there are some explanatory texts on larger screens.

plurals
  1. POError in cascading combobox in windows form in vb.net
    primarykey
    data
    text
    <p>I am Getting error like FormateException was unhandled by usercode. Error String is not in a correct format. can't solve this error. Any Suggestion ? ?</p> <p>I am getting Error In this Line</p> <pre><code>Dim stateid As Integer = Convert.ToInt32(cmbState.SelectedValue.ToString()) </code></pre> <p>Here's my full code</p> <pre><code> Public Class Form1 Private Sub FillState() Dim cn As SqlConnection = New SqlConnection("Data Source=192.168.0.7;Initial Catalog=TraineeDataBaseExamples;Persist Security Info=True;User ID=newtrainee;Password=newtrainee") cn.Open() Dim da As SqlDataAdapter = New SqlDataAdapter(" select * from KaiyumVbState ", cn) Dim ds As New DataSet da.Fill(ds) With cmbState .DataSource = ds.Tables(0) .DisplayMember = "StateName" .ValueMember = "StateID" .SelectedIndex = -1 End With End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load FillState() End Sub Private Sub cmbState_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbState.SelectedIndexChanged If cmbState.SelectedValue.ToString() &lt;&gt; "" Then Dim stateid As Integer = Convert.ToInt32(cmbState.SelectedValue.ToString()) FillCities(stateid) cmbCity.SelectedIndex = -1 End If End Sub Private Sub FillCities(ByVal stateid As Integer) Dim cn As SqlConnection = New SqlConnection("Data Source=192.168.0.7;Initial Catalog=TraineeDataBaseExamples;Persist Security Info=True;User ID=newtrainee;Password=newtrainee") Dim cmd As SqlCommand = New SqlCommand("select CityId,CityName from KaiyumVbCity where StateID = @Stateid ", cn) cmd.Parameters.AddWithValue("@StateId", stateid) Dim da As New SqlDataAdapter() da.SelectCommand = cmd Dim ds As New DataSet() cn.Open() da.Fill(ds) If ds.Tables(0).Rows.Count &gt; 0 Then With cmbCity .DataSource = ds.Tables(0) .DisplayMember = "CityName" .ValueMember = "CityId" End With End If End Sub Private Sub cmbState_AfterUpdate() End Sub End Class </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload