troubleshooting Question

datatable

Avatar of ube100
ube100Flag for United Kingdom of Great Britain and Northern Ireland asked on
Visual Basic ClassicC#
2 Comments1 Solution608 ViewsLast Modified:
Hi,
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
   
    RecAvailability.open
   
    With RecAvailability
            .AddNew
            .fields("StartDate").Value = Format(dteStartDate, "yyyy-mm-dd")
            .fields("Duration").Value = GetDurationCode(intDuration)
        .UpdateBatch
    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
   
    RecHotel.open
   
    With RecHotel
        For i = 0 To moRecRooms.RecordCount - 1
            .AddNew
            .fields("HotelRef").Value = strItemCode
        Next i
        .UpdateBatch
    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)
                  {
                        DS.Tables.Add(dt);
                  }
                  else
                  {
//                        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.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros