I am trying to make a messagebox text provide datatable results. Below is a snippet of code that I have written so far:
String mystring = comboBox1.Text; if (mystring.Substring(0, 12) == ("Company Name")) { textBox2.Text = mystring.Substring(13); ADOCon.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Name\Desktop\SmallBizDb.mdb"; ADOCon.Open();
OleDbCommandBuilder CBuilder = new OleDbCommandBuilder(DAdapter);
DAdapter = new OleDbDataAdapter("Select Companies.Company_Name From Companies Where Companies.Company_Name = '" + textBox2.Text + "'", ADOCon);
DAdapter.Fill(DTable);
MessageBox.Show(DTable.ToString());
ADOCon.Close();
ADOCon.Dispose();
}
else
Basically, if an end user types "Company Name-Company One", for example, I would like a message box to appear stating the datatable (DTable) information, which comes from a sql query. Currently, I have "messagebox.Show(DTable.ToString());", which does not work. Also, all other examples I have seen use Row indexes, such as ".Rows[0]", which I cannot use since row numbers are not involved, but rather column names and record names from the sql "where" statement within the data adapter.
There is a lot fluff here, so my major issue is how to convert my datable results so that they will show up in a message box.
Thank you,
DFM