Strongly Typed DataSet RRS feed

  • Question

  • I am building a little expense application in vs2005 c# and have it a huge roadblock with strongly typed datasets.  I have added a database(MonthlyExpenses) to my project and I know about the 2 copies issues when it copies the database to the bin dir.  I have 3 tables in my database. The current & first one i am working on is categories, So i drag and drop the categories table onto the DataSet Designer(MonthlyExpensesDataSet.xsd). It appears appropiatly and i leave it all as default.


    Categories table:
    category_id(int, identity,PK)
    category_name: nvarchar(50)

    On click of my button i want to add a new category to the table by doing category.category_name = txtCategory.text; then add the category to categories(datatable) then update the database using the tableadapter(categoriesAdapter).update(categories)

    I have hit the roadblock on declaring the Categories row.

    Error 1 Cannot implicitly convert type 'System.Data.DataRow' to 'Expenses.MonthlyExpensesDataSet.CategoriesRow'. An explicit conversion exists (are you missing a cast?) 

    Code is below please help!

    private void btnAddCategory_Click(object sender, EventArgs e)


    MonthlyExpensesDataSetTableAdapters.CategoriesTableAdapter categoriesAdapter = new Expenses.MonthlyExpensesDataSetTableAdapters.CategoriesTableAdapter();

    MonthlyExpensesDataSet.CategoriesDataTable categories ;

    MonthlyExpensesDataSet.CategoriesRow category = categories.NewRow();



    I would really appreciate any help you experts can provide.

    Thanks again

    Saturday, February 10, 2007 6:22 PM





    OrdenCargaDS.T_Orden_CargaRow Fila = m_dsOrdenCarga.T_Orden_Carga.NewT_Orden_CargaRow();

    OrdenCargaDS is Typed Dataset class

    m_dsOrdenCarga is variable member

    using method NewTableNameRow();

    in your case

    MonthlyExpensesDataSet.CategoriesRow category = categories.NewCategoriesRow();


    Tuesday, March 6, 2007 6:52 PM