none
Typed Datasets RRS feed

  • Question

  • 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.

            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)

    Thursday, July 11, 2019 3:00 PM

All replies

  • Hello,

    A TableAdapter uses SQL too, just not seen unless “Show all” menu item is clicked on the project menu item in Visual Studio.

    With a Typed DataSet via TableAdapter, classes are generated at design time while DataAdapter generates standard SQL statements (or you create them) at runtime. A TableAdapter is what could be called a heavier weight solution as the underlying code that is generated via the data wizard places code in that may not be needed but comes with regardless as the generator knows only one way to generate code.

    See the following Typed vs. untyped datasets.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Thursday, July 11, 2019 5:34 PM
    Moderator
  • Thank you for your reply.

    What I am after here is the correct sequence of coding to manipulate.  It is my understanding I can just refer to the dataset, or automated table adapter and do an Update.  After this, all of the data would be updated from the source, in my case arrays, to the tables in sql. 

    I am just not finding this information anywhere.  Is there a book you would recommend for this, because I do have a Safari Subscription.

    Thursday, July 11, 2019 9:18 PM
  • Hi,

    see the following link,SqlDataAdapter and  SqlCommand

    https://docs.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqldataadapter?view=netframework-4.8

    https://docs.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlcommand?view=netframework-4.8

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, July 17, 2019 5:53 AM
    Moderator