Manu Laureys

Manu Laureys

  • NA
  • 40
  • 1.8k

SQL in C# with OLEDB and datagridview

Apr 7 2022 2:46 PM

I have a SQL select that works in MS Access, but when I put it in C# I get an error (Error in From).

This is the code I use to fill my datagridview:

                // Bind data to datagrid
                strCmd = "Select Serial.ID, Serial.Datum, Product.Type, Product.Omschrijving, Serial.SerialNumber, Serial.Chassis, Serial.WOrder, Serial.VOrder, Klant.Naam, User.Init" +
                    " From ((Serial Left Join Product On Serial.ProductID = Product.ID)" +
                    " Left Join Klant On Serial.KlantID = Klant.ID)" +
                    " Left Join User On Serial.UserID = User.ID" +
                    " Where Serial.ProductID = 61" +
                    " Order By Serial.SerialNumber";
                MessageBox.Show("Sql: " + strCmd);
                OleDbDataAdapter da = new OleDbDataAdapter(strCmd, conn);
                DataSet ds = new DataSet();
                da.Fill(ds, "Serial");

                dgrSerial.DataSource = ds;
                dgrSerial.DataMember = "Serial";
 


Answers (1)