Posted on 2009-12-18
Last Modified: 2012-05-08
My VB application is producing this recordset object:

 Set RecAvailability = CreateObject("ADOR.Recordset")
    With RecAvailability.fields
            Call .Append("StartDate", adBSTR, , adFldIsNullable)
            Call .Append("Duration", adBSTR, , adFldIsNullable)
    End With
    With RecAvailability
            .fields("StartDate").Value = Format(dteStartDate, "yyyy-mm-dd")
            .fields("Duration").Value = GetDurationCode(intDuration)
    End With
    'Create the recordset for the room hotel reference.
    Set RecHotel = New ADOR.Recordset
    With RecHotel.fields
            Call .Append("HotelRef", adBSTR, , adFldIsNullable)
    End With
    With RecHotel
        For i = 0 To moRecRooms.RecordCount - 1
            .fields("HotelRef").Value = strItemCode
        Next i
    End With

Once it done that it calling a .net function:
Call tmsGDS.AddRecordset(RecAvailability, "Availability")
 Call tmsGDS.AddRecordset(RecHotel, "Hotel")

And the .net functions are:

public bool AddRecordset(ADOR.Recordset rs, string name)
                  // Convert the recordset to a dataset
                  OleDbDataAdapter myDA = new OleDbDataAdapter();
                  DataTable myDT = new DataTable(name);
                  myDA.Fill(DS, rs, name);
                  bool ret = AddDataTable(myDT, name);
                  return ret;

public bool AddDataTable(DataTable dt, string name)
                  if (DS.Tables[name] == null)
//                        DataRow dr;
//                        dr = DS.Tables[name].NewRow();
//                        dr[0] = DS.Tables[name].Rows[0].ToString();
//                        DS.Tables[name].Rows.Add(dr);

Since the VB producing single value as a recordset in turn each recordset is created as a datatable in the .net. But the trouble is the way this .net function is implemented it cannot take any more than one value for a repeating row as it will ignore that row because that table name already exists in the dataset. AS you can see from the "AddDataTable" function else claues I have commented out should be handling this scenario but that's not doing that at the moment. Can somebody show me how can I achieve this please.
Question by:ube100
    LVL 10

    Expert Comment

    dont understand what you are doing here:

    from AddRecordset you are calling: myDA.Fill(DS, rs, name);
                      bool ret = AddDataTable(myDT, name);
    instead you should pass DS to AddDataTable
    in AddDataTable you should then use DS.Tables[name]
    LVL 6

    Accepted Solution

    You cannot add DataRows from one DataTable to another, you have to Import them using the ImportRow() method
    DataRow dr;
    dr = DS.Tables[name].NewRow();
    dr[0] = DS.Tables[name].Rows[0].ToString();

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
    Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now