hi, I had modified your function:
string conStr = "Provider=Microsoft.Jet.OLEDB.4.0;" +
" Data Source=..\\..\\studentDB.mdb";
private void fnGetConnectedToDatabase()
{
try
{
myConn = new OleDbConnection(conStr);
myConn.Open();
}
catch (OleDbException ex)
{
MessageBox.Show("Error in connection ..." + ex.Message);
}
string sqlStr = "SELECT * FROM studentTable;";
dAdapter = new OleDbDataAdapter(sqlStr, myConn);
dset = new DataSet();
dAdapter.Fill(dset);
this.comboBox1.DataSource = ds;
this.comboBox1.DisplayMember = "StudentID";
this.myConn.Close();
}
[edited]
to load related values in Textboxes
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
myConn = new OleDbConnection(conStr);
myConn.Open();
}
catch (OleDbException ex)
{
MessageBox.Show("Error in connection ..." + ex.Message);
}
string sqlStr = "SELECT * FROM studentTable wehre StudentID="+comboBox1.SelectedValue.ToString()+";";
dAdapter = new OleDbDataAdapter(sqlStr, myConn);
dset = new DataSet();
dAdapter.Fill(dset);
this.textBox1.Text=ds.Table[0].Rows[0]["StudentID"].ToString();
this.textBox2.Text = ds.Table[0].Rows[0]["StudentSubject"].ToString();
this.textBox3.Text = ds.Table[0].Rows[0]["StudentName"].ToString();
}
hope this help you.