❔ Database to Combo Box linking without using SQL??

Hello. I'm using winforms/visual studio and I just wanna ask if anybody has a way to link an access database into a combo box without using SQL. I'm doing this for a school project and for some reason our professor prohibited us from using SQL, the system I'm tasked to do (Voting System) happens to be heavily reliant on database works and everything I see online requires it to work
No description
4 Replies
JakenVeina
JakenVeina14mo ago
BindingList is the database-driven wrapper, right? The one that DataGrid uses? Does ComboBox support that at all?
𝚂𝚝𝚊𝚙𝚕𝚎𝚜
Update: I managed to find a solution by playing around with OleDb data reader and stuff, here's what I did
private void FORMNAME_Load(object sender, EventArgs e)
{
try
{
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
string query = "select * from DATATABLE";
command.CommandText = query;

OleDbDataReader reader = command.ExecuteReader();
while (reader.Read())
{
COMBOBOXNAME.Items.Add(reader["DATAFIELD"]);
}

connection.Close();
}
catch (Exception ex)
{
MessageBox.Show("Error " + ex);
}
}
}
private void FORMNAME_Load(object sender, EventArgs e)
{
try
{
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
string query = "select * from DATATABLE";
command.CommandText = query;

OleDbDataReader reader = command.ExecuteReader();
while (reader.Read())
{
COMBOBOXNAME.Items.Add(reader["DATAFIELD"]);
}

connection.Close();
}
catch (Exception ex)
{
MessageBox.Show("Error " + ex);
}
}
}
JakenVeina
JakenVeina14mo ago
uhh... how does select * from DATATABLE not count as using SQL?
Accord
Accord14mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server