Thanks john
The idea you provided is almost working after tweaking it;here is the code am using for entering pupil code
Dim
i As Integer = 0
While i < ListBox1.Items.Count
SetSelection(
True)
commandString =
"INSERT INTO enrolnment (pupilCode) VALUES('"+listBox1.items.Tostring() +"' );"
con.ConnectionString =
"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\simple.mdf;Integrated Security=True;User Instance=True"
con.Open()
cmd.Connection = con
cmd.CommandText = commandString
DisplayMessage(
"Records Added Successfully")
cmd.ExecuteNonQuery()
DisplayMessage(
"Records NOT Added")
con.Close()
System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
end while
This is able to add the exact records from the listbox into db but with a wrong format. am getting these system.web.ui.webcontrols.listbox in the database instead of the pupilcode. How do i get the pupilcode into db.using selecteditems am getting error, selecteditems is not a member of system.web.ui.webcontrol.listbox