2 replies
by ofentseboikanyo Accepted solution
by tony hopkinson Accepted solution
Assuming you have the Mysqlconnector installed.
Look for Mysql.data.msi on google, if you haven't
connection = new MySqlConnection("server=myserver; user id = myuser; password = mypassword; datanase = mydatabase")
MySqlCommand command = connection.CreateCommand();
command.commandtext = "Select Key,Value from mytable";
MySqlDataReader reader = command.Execute();
MyComboxBox.Items.Clear();
While (reader.read())
{
comoboval = new comboval(reader[key],reader[value]);
mycombo.items.add(comboval);
}
If you are only interested in the text you could forget the comboval class and just do
, mycombo.items.add(reader[value]);
If you aren't creating an inflatable dartboard.
They bash up the class and override the ToString() method return value.
PS that msi file comes with a nice swadge of examples.
PPS, this was off teh top of my head, so expect one or two syntax errors, probably Add instead of add for starters.
This discussion is closed to new replies.
Trending Microsoft posts
Sort by Trending