ube100
asked on
datatable
Hi,
My VB application is producing this recordset object:
Set RecAvailability = CreateObject("ADOR.Records et")
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(intDuratio n)
.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(RecAva ilability, "Availability")
Call tmsGDS.AddRecordset(RecHot el, "Hotel")
And the .net functions are:
public bool AddRecordset(ADOR.Recordse t 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].To String();
// DS.Tables[name].Rows.Add(d r);
}
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.
My VB application is producing this recordset object:
Set RecAvailability = CreateObject("ADOR.Records
With RecAvailability.fields
Call .Append("StartDate", adBSTR, , adFldIsNullable)
Call .Append("Duration", adBSTR, , adFldIsNullable)
End With
RecAvailability.open
With RecAvailability
.AddNew
.fields("StartDate").Value
.fields("Duration").Value = GetDurationCode(intDuratio
.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(RecAva
Call tmsGDS.AddRecordset(RecHot
And the .net functions are:
public bool AddRecordset(ADOR.Recordse
{
// 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].To
// DS.Tables[name].Rows.Add(d
}
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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]