How to save ITEMS on listbox to MySQL Database in vb.net....
plz reply...

Using Insert (SQL) statement.

Assuming that I have 5 items in the listbox and i want it to save to the five fields of the my mysql database..

can you show me some codes...??
thank you.

...
_cmd=new MySqlCommand();
...
_cmd.CommandText="insert into table Test values(?col1,?col2,?col3,?col4,?col5)"
_cmd.Parameters.AddWithValue("?col1", listbox1.items(0))
_cmd.Parameters.AddWithValue("?col2", listbox1.items(1))
_cmd.Parameters.AddWithValue("?col3", listbox1.items(2))
_cmd.Parameters.AddWithValue("?col4", listbox1.items(3))
_cmd.Parameters.AddWithValue("?col5", listbox1.items(4))
...
Dim my_cmd As MySqlCommand
                        my_cmd = New MySqlCommand()
                        my_cmd.CommandText = "insert into documenttable Test values(?route1,?route2,?route3,?route4,?route5,?route6,?route7,?route8,?route9,?route10,?route11,?route12)"
                        rs.Open(query, conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)
                        my_cmd.Parameters.AddWithValue("?route1", .ListBox1.Items(0))
                        my_cmd.Parameters.AddWithValue("?route2", .ListBox1.Items(1))
                        my_cmd.Parameters.AddWithValue("?route3", .ListBox1.Items(2))
                        my_cmd.Parameters.AddWithValue("?route4", .ListBox1.Items(3))
                        my_cmd.Parameters.AddWithValue("?route5", .ListBox1.Items(4))
                        my_cmd.Parameters.AddWithValue("?route6", .ListBox1.Items(5))
                        my_cmd.Parameters.AddWithValue("?route7", .ListBox1.Items(6))
                        my_cmd.Parameters.AddWithValue("?route8", .ListBox1.Items(7))
                        my_cmd.Parameters.AddWithValue("?route9", .ListBox1.Items(8))
                        my_cmd.Parameters.AddWithValue("?route10", .ListBox1.Items(9))
                        my_cmd.Parameters.AddWithValue("?route11", .ListBox1.Items(10))
                        my_cmd.Parameters.AddWithValue("?route12", .ListBox1.Items(11))

"It does not work with this command...."
can show show me line by line.???

my_cmd.CommandText = "insert into documenttable values(?route1,?route2,?route3,?route4,?route5,?route6,?route7,?route8,?route9,?route10,?route11,?route12)"

i already try that..
but the same had happen...

Is there any way that I can help? Tell me about your program please.

1. Name of Table
2. Number of columns and type of each column

my program have two listbox which we say as listbox1 and listbox2 and two command button b1 and b2. listbox1 contains items list.like chicken, frog and etc. when i choose chicken and i clicked b1 the item chicken is remove from listbox1 and goes to listbox2 and so on.Now when I clicked b2 it must be save into mysql database.but how???

I think you have solved your problem yourself. Thanks!

bit I cannot save the items on the listbox.

Be a part of the DaniWeb community

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