Team,
I have 2 listboxs. Listbox 1 as name listbox 2 as sex
what i need is when i press a button in vb. the first value of both listbox alone should be inserted to sql. once its inserted those value should alone remove and till both list box is empty.
I had this below code. i know am doing things wrong please correct me. this code is creating duplicate and Nullvalue.
For i = 0 To ListBox1.Items.Count - 1
For j = 0 To ListBox2.Items.Count - 1
selected = ListBox1.Items(i).ToString
selected1 = ListBox2.Items(i).ToString
MsgBox(selected)
con.ConnectionString = "Provider=SQLOLEDB.1;Password=$impadmins123;Persist Security Info=True;User ID=simp;Initial Catalog=Employee Information;Data Source=SRAVI6"
con.Open()
cmd.Connection = con
cmd1.Connection = con
cmd.CommandText = "insert into tic (name) values ('" & selected & "')"
cmd1.CommandText = "insert into tic (new) values ('" & selected1 & "')"
cmd.ExecuteNonQuery()
cmd1.ExecuteNonQuery()
con.Close()
Next
Next