dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Typed Datasets

  1. #1
    Join Date
    Jul 2019
    Posts
    3

    Typed Datasets

    Hello:

    I have this very inconsistent code that may be mixing untyped and typed datasets. My goal is to have a typed dataset where I can just say dataset.Update to get any new information or changes.

    I have read through several articles and am unable to relate what I am doing to them. I am using a table adapter to update my dataset, have no idea if that is right because every example I look at us using data adapters, which require sql statements. It seems to me that if I already have the dataset available for use, then why would I need a sql statement?

    I also would not mind creating an instance of my table adapter rather than referring to it directly, but am concerned this is only for untyped datasets.

    My code below also does add rows, because this is the only way I could get it to work. The problem is, the update only happens once this way.

    I need to understand the difference between typed and untyped as far as coding is concerned.

    Thank you for the help.

    Code:
            JobSheetDataSet.CaseSensitive = False
    
            Dim ta_JobInfo As JobSheetDataSetTableAdapters.JobInfoTableAdapter = New JobSheetDataSetTableAdapters.JobInfoTableAdapter
            ta_JobInfo.Fill(JobSheetDataSet.JobInfo)
    
            Dim JobInfoRow As DataRow = JobSheetDataSet.JobInfo.NewRow
            With JobInfoRow
                .Item("JobNo") = JobNo
                .Item("ProjectItem") = ProjectItem
                .Item("DrawingNo") = DrawingNo
                .Item("Started") = Started ' date
                .Item("Completed") = Completed ' date
                .Item("ToProd") = Completed ' date
                .Item("Engineer") = Engineer
                .Item("Designer") = Designer
                .Item("EstHrs") = EstHrs ' decimal
                .Item("Checker") = Checker
                .Item("EngineeringJobNotes") = EngineeringJobNotes
                .Item("ShipTo") = ShipTo
                .Item("ShipDate") = ShipDate ' date
                .Item("FMLDrawingNo") = FMLDrawingNo
    
            End With
    
            Try
                JobSheetDataSet.JobInfo.Rows.Add(JobInfoRow)
    
            Catch
    
            End Try
    
            ta_JobInfo.Update(JobSheetDataSet.JobInfo)

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,032

    Re: Typed Datasets

    How about taking a look at Entity Framework or Entity Framework Core or some other orm?

  3. #3
    Join Date
    Jul 2019
    Posts
    3

    Re: Typed Datasets

    Perhaps. Is this what is recommended?

    As I understand it, I am supposed to be able to use the typed dataset and table adapter to just update, and this takes my array based source and automatically updates the data tables, one table at a time. There are no sql statements, and it always knows what to do (insert, change or delete) based on the update command.

    I have reviewed several books and articles, all of which use references for untyped datasets.

    Can you recommend a good reference, or provide clarification? As I understand Entity Framework, it too requires sql statements.

    Thank you for your reply.

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,032

    Re: Typed Datasets

    I would say using an orm like EF is recommended over data sets. If you are using EF properly, it shouldn't require having to write sql (there are exceptions to this, but using the latest EF helps to minimize having to fall back to hand writing SQL).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)