0

Private Sub ComboBox6_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox6.SelectedIndexChanged
con = New SqlConnection("Data Source=DEW-D63D9D2D032\SQLEXPRESS;Initial Catalog=system1;Integrated Security=True")
con.Open()
sql = "Select Faculty_Id From Faculty where Faculty_Name='" + ComboBox6.SelectedItem.ToString() + "'"
cmd = New SqlCommand(sql, con)
rdr = cmd.ExecuteReader()
While (rdr.Read())
fid = rdr.GetInt32(0)
End While

con.Close()

MsgBox(fid)

con1 = New SqlConnection("Data Source=DEW-D63D9D2D032\SQLEXPRESS;Initial Catalog=system1;Integrated Security=True")
con1.Open()
sql1 = "Select Department_Name From Department_Master where Faculty_Id=" + fid
cmd1 = New SqlCommand(sql1, con1)
rdr1 = cmd1.ExecuteReader()
While (rdr1.Read())
ComboBox7.Items.Add(rdr1.GetString(0))
End While
con1.Close()
its gives an error
here fid is fk in department table

1
Contributor
2
Replies
3
Views
5 Years
Discussion Span
Last Post by dew97
0

Conversion from string "Select Department_Name From Depa" to type 'Double' is not valid.

0

on insert and select for int we need to used syntax as & fid &

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.