PDS8475
Active member
- Joined
- Jun 25, 2019
- Messages
- 41
- Programming Experience
- Beginner
Hi
I have a problem with the following query
I am using this to filter the results and it fetches the right results in the DataGridView, However the first 4 columns are named "TableName.ColumnName" and the rest are just "ColumnName"
How can I stop the first four columns from showing the table name.
There is another 3 DataGridViews on the form using the same code but with a different query and they all work fine. I have even copied the code from this and the code for filtering a working dataGridView and they are identical apart from the query.
The code that I am using is below
I have a problem with the following query
"Select * FROM ItemsForSale INNER JOIN Engineering ON Engineering.Serial = ItemsForSale.Serial WHERE Engineering.Name = @s"
I am using this to filter the results and it fetches the right results in the DataGridView, However the first 4 columns are named "TableName.ColumnName" and the rest are just "ColumnName"
How can I stop the first four columns from showing the table name.
There is another 3 DataGridViews on the form using the same code but with a different query and they all work fine. I have even copied the code from this and the code for filtering a working dataGridView and they are identical apart from the query.
The code that I am using is below
C#:
string iConString = System.IO.File.ReadAllText("FixIT.con");
iConString = iConString.Replace(System.Environment.NewLine, string.Empty);
System.Data.OleDb.OleDbConnection iconnn = new System.Data.OleDb.OleDbConnection();
string iconnsString = "Provider = Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + iConString;
try
{
using (OleDbConnection iconnection = new OleDbConnection(iconnsString))
{
using (OleDbCommand icommand = new OleDbCommand("Select * FROM ItemsForSale INNER JOIN Engineering ON Engineering.Serial = ItemsForSale.Serial WHERE Engineering.Name = @s", iconnection))
{
icommand.CommandType = CommandType.Text;
icommand.Parameters.AddWithValue(@s, Details1_textBox.Text);
using (OleDbDataAdapter iDA = new OleDbDataAdapter(icommand))
{
using (DataTable iDT = new DataTable())
{
ItemsForSale_dataGridView.Columns[4].Name = "Serial";
iDA.Fill(iDT);
ItemsForSale_dataGridView.DataSource = iDT;
}
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
TextWriter tw = new StreamWriter("ex.txt");
tw.WriteLine(ex);
tw.Close();
}
Last edited: