473,598 Members | 3,324 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Populating disconnected ADODB.Recordset with System.Data.Dat aTable data.

I need to support a VB6 application that will be receiving
disconnected ADODB.Recordset from out DotNet solution. Our dotnet
solution deals with System.Data.Dat aTable. I need to populate a
disconnected ADODB.Recordset from System.Data.Dat aTable data. Below
is the source code I am implementing to test the process. I do not
get any error, that I can see. The problem I have is that at the end,
the recordset seems to be empty. Any suggestions are very much
appreciated. At this moment I do not know what to do.
Thank you so much for the time and effort you may spend on this
matter.
Elcc.
private bool testConvertDT_R S()
{
System.Data.Dat aTable dt;
ADODB.Recordset rs;

// create dummy data table.
dt = PopulateDataTab le( );

// attempt to populate disconnected ADODB.Recordset
with System.Data.Dat aTable data
rs = ConvertToRS ( dt );

if( null == rs )
{
throw new Exception(" Recordset is null.");
}

if( 0 == rs.Fields.Count )
{
throw new Exception(" Recordset Field count is zero.");
}

return true;
}
private System.Data.Dat aTable PopulateDataTab le()
{

System.Data.Dat aTable dt = new System.Data.Dat aTable();
System.Data.Dat aRow dr;
string[,] ColValues = {{"R1-C1", "R2-C1", "R3-C1", "R4-C1", "R5-C1"}
, {"R1-C2", "R2-C2", "R3-C2", "R4-C2", "R5-C2"} ,
{"R1-C3", "R2-C3", "R3-C3", "R4-C3", "R5-C3"}};

dt.Columns.Add( new System.Data.Dat aColumn("Column 01",
System.Type.Get Type("System.St ring")));
dt.Columns.Add( new System.Data.Dat aColumn("Column 02",
System.Type.Get Type("System.St ring")));
dt.Columns.Add( new System.Data.Dat aColumn("Column 03",
System.Type.Get Type("System.St ring")));
for( int i = 0 ; i < 5 ; i++ )
{
dr = dt.NewRow();
for( int n = 0 ; n < 3 ; n++ )
{
dr[n] = ColValues[ n, i];
}
dt.Rows.Add(dr) ;
}
return dt;
}
private ADODB.Recordset ConvertToRS(Sys tem.Data.DataTa ble dt)
{
ADODB.Recordset rs = new ADODB.Recordset ();

try
{

rs.CursorLocati on = ADODB.CursorLoc ationEnum.adUse Client;
rs.ActiveConnec tion = null;

for( int i = 0; i < dt.Columns.Coun t; i++)
{
rs.Fields.Appen d( dt.Columns[i].ColumnName,
ADODB.DataTypeE num.adBSTR,
dt.Columns[i].MaxLength,
ADODB.FieldAttr ibuteEnum.adFld Unspecified,
null );
}
rs.Open( Type.Missing,
Type.Missing,
ADODB.CursorTyp eEnum.adOpenSta tic,
ADODB.LockTypeE num.adLockOptim istic,
-1);
foreach(System. Data.DataRow dr in dt.Rows)
{
rs.AddNew(Type. Missing, Type.Missing);

for( int n = 0; n < dt.Columns.Coun t; n++)
{
rs.Fields[n].Value = dr[n];
}

rs.Update(Type. Missing, Type.Missing);

}

rs.Close();
return rs;

}
catch(Exception e)
{
throw e;
}

}
Jul 21 '05 #1
0 2860

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
4070
by: Drew | last post by:
I have a db table like the following, UID, int auto-increment RegNo Person Relation YearsKnown Now here is some sample data from this table,
0
2472
by: Channing Jones | last post by:
Hello everyone, I am trying to store data in a binary field of an SQL-Server table using ADODB. So far, I have managed to store a record but not any data in the binary field. I only get exceptions on various part. I have tried both AppendChunk and using a stream object. Unfortunately all the examples I can find in the Net and on the Microsoft site
8
6797
by: Roy Padgett | last post by:
I have a combo box where users select the customer name and can either go to the customer's info or open a list of the customer's orders. The RowSource for the combo box was a simple pass-through query: SELECT DISTINCT , , ,City, Region FROM Customers ORDER BY Customers.; This was working fine until a couple of weeks ago. Now whenever someone has the form open, this statement locks the entire Customers table.
0
4673
by: Ireneus Broncel | last post by:
I have a class which reads Groups and Users from ActiveDirectory. The Problem is, that i have about 10000 rows as product. When I am trying to read the "memberOf" Objects out of this field i get allways different count of rows. If anybody knows something about this kind of problem, I would appreciate any help. Thx.
2
2909
by: collie | last post by:
Hi, I have 2 listboxes. The first gets populated from the db as soon as the page loads. The second listbox get populated based on the user's selection from the first listbox. However, currently the code is such that with each selection there is a postback. We want to avoid it using filter and javascript. I am not using ADO.NET but adodbc and no datagrids or datasets (please don't tell me that i should as my boss clearly doesn't want...
5
2270
by: | last post by:
Trying to learn about manipulating collections of objects, and populating these objects dynamically from datasources. Could someone post a code sample that shows the following: Instantiating a collection object -- say, a dictionary. Populating that collection object with custom objects, say, Person. What I really want to see is how to populate the properties of those Person objects from a datasource: instantiate one Person, fill...
2
2867
by: Eric Peterson | last post by:
I use the shape object to make recordsets that have no db connection for use in grids and such. For example (mPhoneNumbersRS as ADODB.Recordset) **************************************** mPhoneNumbersRS.let_ActiveConnection ("Provider=MSDataShape;Data Provider=none;Data Source=localhost;") sTmp = "SHAPE APPEND NEW adChar(20) as Type, NEW advarChar
0
628
by: elcc1958 | last post by:
I need to support a VB6 application that will be receiving disconnected ADODB.Recordset from out DotNet solution. Our dotnet solution deals with System.Data.DataTable. I need to populate a disconnected ADODB.Recordset from System.Data.DataTable data. Below is the source code I am implementing to test the process. I do not get any error, that I can see. The problem I have is that at the end, the recordset seems to be empty. Any...
0
3505
by: Screaming Eagles 101 | last post by:
Not sure in which group to post, sorry... We are using VB2005 on Windows XP. After getting my data in a datatable and parse it to a recordset according to the method on http://www.codeproject.com/cs/database/DataTableToRecordset.asp , which learned us to convert an ADO.Net datatable to an ADODB.Recordset, needed by the Microsoft Office Spreadsheet Web Component (OWC11), we got an error on the checking of a TIME column.
0
8395
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8398
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8050
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6719
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5850
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3939
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2412
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1504
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1250
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.