Select statement from a view . . . not a table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CodeNoobster
    New Member
    • Sep 2013
    • 52

    Select statement from a view . . . not a table

    I am currently using generic select statements to display all info from tables, but the need to display info from an existing view in the database has come and I am finding some difficulty with the process

    Code:
    DBcon2.Open();
    Query_text = DBcmd.CommandText = "SELECT * FROM Customer";
    DB_table_info = new OleDbDataAdapter(Query_text,DBcon2);
    DB_dataset = new DataSet();
    DB_table_info.Fill(DB_dataset, "Customer");
    D_G_View_Customer.DataSource = DB_dataset.Tables["Customer"];
    The code above represents a typical procedure of selecting all info from the specified table

    but now with regards to selecting info from a view
    Code:
    Query_text = DBcmd.CommandText = "SELECT * FROM [Product_Join_Supplier]";
    I am having difficulty with the OleDbDataAdapte r(DB_table_info ) fill method and dataset.tables property since they only recognize valid table names and not views. im trying to populate the datagridview with the info from the existing view in the database.

    any suggestions for how to go about doing this?

    PS: I am well aware of the benefits of using parameters but I have not had a problem with the coding style I am using at the moment and SQL injection and the moment is not a problem so any suggestion with out the use of parameters would be greatly appreciated.
Working...