• C# How to Get data from my database table and display it using a table field

    Aleisha Member

    I’m using visual studio and using c#. I have created a database for a local shop. The database contains tables (CategoryTable, ProductTable, TransactionItemTable, TransactionTable). I have a a combo box, i want to get data from my database table and display it using a field within a table. I have attempted the following:

    private UWSUShopDatabaseEntities usde = new UWSUShopDatabaseEntities();
    

    in form itself

    InitializeComponent();
    cboCategory.DataSource = usde.CategoryTable;
    cboCategory.DisplayMember = "Description";
    cboCategory.ValueMember = "Product Type";
    
    Error 1 'UWSUShopManagmentSystem.UWSUShopDatabaseEntities' does not contain a definition for 'CategoryTable' and no extension method 'CategoryTable' accepting a first argument of type 'UWSUShopManagmentSystem.UWSUShopDatabaseEntities' could be found (are you missing a using directive or an assembly reference?) C:\Users\Usman\Desktop\UWSU Managment System\UWSUShopManagmentSystem\UWSUShopManagmentSystem\AddItem.cs 21 43 UWSUShopManagmentSystem
    
  • Amit Member

    Why don’t you use the property to set a database to the combo box from the smart tag?

Viewing 1 reply thread
  • You must be logged in to reply to this topic.