Just started coding C# and I'm an absolute beginner at it. That being said, I have a question about using MySqlConnector and mysql query's.
I currently have a query and with it I fill a listbox with the results. But what I like to do is add more query's to the reader and put the result of those other query in a combobox. So how do I do this? I searched google and couldn't find an answer.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace Badminton_stand
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
labelCurrentTime.Text = DateTime.Now.ToString();
}
private void Form1_Load(object sender, EventArgs e)
/* {
string MyConString = "Server=localhost;Port=3307;Database=database1;UID=root;Password=toor";
MySqlConnection connection = new MySqlConnection(MyConString);
MySqlCommand command = connection.CreateCommand();
MySqlDataReader Reader;
command.CommandText = @"select Club from teams;
select team from teams";
connection.Open();
Reader = command.ExecuteReader();
while (Reader.Read())
{
string thisrow = "";
for (int i = 0; i < Reader.FieldCount; i++)
thisrow += Reader.GetValue(i).ToString() + " ";
clubSelectorBox1.Items.Add(thisrow);
}
while (Reader.NextResult()) ;
{
string thisrow = "";
for (int i = 0; i < Reader.FieldCount; i++)
thisrow += Reader.GetValue(i).ToString() + " ";
cbTeam1.Items.Add(thisrow);
}
connection.Close();
} */
{
string cmdText = @"SELECT Club from teams;
SELECT team from teams";
using (MySqlConnection cnn = new MySqlConnection("Server=localhost;Port=3307;Database=badminton;UID=root;Password=usbw"))
using (MySqlCommand cmd = new MySqlCommand(cmdText, cnn))
{
cnn.Open();
using (MySqlDataReader reader = cmd.ExecuteReader())
{
do
{
while (reader.Read())
{
string thisrow = "";
for (int i = 0; i < reader.FieldCount; i++)
thisrow += reader.GetValue(i).ToString() + " ";
clubSelectorBox1.Items.Add(thisrow);
}
}
while (reader.NextResult());
{
}
}
}
}
}
}
Thanks in advance!