I am returning a data table of one row, then i set the primary key of the datatable and then looking for that column. I then want to assign the value which is returned from the company column into txtCompany.
Here is what I have tried:
private void comboBox1_SelectedItem(object sender, EventArgs e)
{
MessageBox.Show("Populating form");
m_dbConnection.Open();
DataTable dt = new DataTable();
SQLiteCommand command = m_dbConnection.CreateCommand();
command.CommandText = "select * from rdpdirectory where company = @company order by company asc";
//
command.Parameters.Add(new SQLiteParameter("@company", comboBox1.SelectedText));
SQLiteDataAdapter db = new SQLiteDataAdapter(command);
db.Fill(dt);
//return dt;
DataColumn[] keyColumns = new DataColumn[1];
keyColumns[0] = dt.Columns["company"];
dt.PrimaryKey = keyColumns;
DataRow row = dt.Rows.Find("company");
if (row != null)
txtCompany.Text = row["company"].ToString();
}