Convert ADODB recordset into .Net dataset

T

Tor Christian

Hi

I am using a VB6 client which connects to a web service using soap3.0
The client is querying a MSDE and filling up a ADODB.recordset. What I
am trying to acomplish is to send this recordset to the web service
where it will be inserted into another MSDE. Much like a batch job.

The client
-------------------------------------------------------------------------
Dim r As ADODB.Recordset
Dim xml as string
Set r = m_us.db.connection1.Execute("Select * from status") 'Get a
recordset from an ado wrapper

r.Save "c:\doit.xml", adPersistXML ' Save the recordset to disk in XML
format
xml=readXmlFromDisk()'Read the xml from disk into a string

m_service.uploadData(xml)'Use soap to send the string to the
webservice

The web service using C#
--------------------------------------------------------------------------
[WebMethod]
public bool uploadData(string data)
{
//How do I grab the xml string and insert the data into a table?
//My best suggestion is to convert the XML string into a dataset(don`t
know how)
//and save this dataset into the MSDE
}


Thanks

Tor Christian
 
P

Prabhat

Hi,

I have a ADO Recordset (rsImages) which is having "Select * FROM EMP"
I am executing the folowing code:

Dim ds As DataSet = New DataSet("PluImages")
Dim da As OleDbDataAdapter = New OleDbDataAdapter()

da.Fill(ds, rsImages, "PluImages")
ds.WriteXml("PluImages.xsd")

After this I am able to get the DataSet to use in my Crystal Report in
VB.NET 2002 as the report source/data source.

But if I Open the xsd file I get an error "Document Element Must be a
schema".

Can anybody help me to do so. I have to use a dataset for my report by my
dataset is filled from a recordset.

Thanks
Prabhat

Ravikanth said:
Hi

Hi,

Yes, you can convert an ADO Recordset into an ADO.NET
Dataset. You can
use the OleDbDataAdapter to get rows from an
ADODB.Recordset and the
ADODB.Record and put them in a DataSet.

The following C# code using System.Data.OleDb namespace
will accomplish
this.

{
//Code creates an ADODB Recordset using the Northwind.mdb
database.
//You will need to change the path to point to the
database on
your system.
//You could also be using a recordset returned from
another
location or Component

ADODB.Recordset MyRs= new ADODB.Recordset();
ADODB.Connection MyCn = new ADODB.Connection();

MyCn.Open("Provider=Microsoft.Jet.OLEDB.4.0;data
source=D:\\Northwind.mdb","Admin","",0);
MyRs.Open("Select * from
Customers",MyCn,ADODB.CursorTypeEnum.adOpenStatic,
ADODB.LockTypeEnum.adLockOptimistic,0);

//Create and fill the dataset from the recordset and
populate
grid from Dataset.
OleDbDataAdapter myDA = new OleDbDataAdapter();
DataSet myDS = new DataSet("MyTable");
myDA.Fill(myDS, MyRs, "MyTable");

dataGrid1.DataSource = myDS;
dataGrid1.DataMember="MyTAble";

//Close and destroy ADODB Objects
//Note that the OleDbDataAdapter.Fill overload that takes
//a DataTable and an ADO object implicitly calls Close on
//the ADO object when the Fill operation is complete.

MyCn.Close();
}

Hope this information is helpful.


Ravikanth[MVP]

-----Original Message-----
Hi

I am using a VB6 client which connects to a web service using soap3.0
The client is querying a MSDE and filling up a ADODB.recordset. What I
am trying to acomplish is to send this recordset to the web service
where it will be inserted into another MSDE. Much like a batch job.

The client
--------------------------------------------------------- ----------------
Dim r As ADODB.Recordset
Dim xml as string
Set r = m_us.db.connection1.Execute("Select * from status") 'Get a
recordset from an ado wrapper

r.Save "c:\doit.xml", adPersistXML ' Save the recordset to disk in XML
format
xml=readXmlFromDisk()'Read the xml from disk into a string

m_service.uploadData(xml)'Use soap to send the string to the
webservice

The web service using C#
--------------------------------------------------------- -----------------
[WebMethod]
public bool uploadData(string data)
{
//How do I grab the xml string and insert the data into a table?
//My best suggestion is to convert the XML string into a dataset(don`t
know how)
//and save this dataset into the MSDE
}


Thanks

Tor Christian
.
 
P

Prabhat

Hi All.

Sorry! I Got that
That should be

ds.WriteXmlSchema("PluImages.xsd")

Thanks
Prabhat

Prabhat said:
Hi,

I have a ADO Recordset (rsImages) which is having "Select * FROM EMP"
I am executing the folowing code:

Dim ds As DataSet = New DataSet("PluImages")
Dim da As OleDbDataAdapter = New OleDbDataAdapter()

da.Fill(ds, rsImages, "PluImages")
ds.WriteXml("PluImages.xsd")

After this I am able to get the DataSet to use in my Crystal Report in
VB.NET 2002 as the report source/data source.

But if I Open the xsd file I get an error "Document Element Must be a
schema".

Can anybody help me to do so. I have to use a dataset for my report by my
dataset is filled from a recordset.

Thanks
Prabhat

Ravikanth said:
Hi

Hi,

Yes, you can convert an ADO Recordset into an ADO.NET
Dataset. You can
use the OleDbDataAdapter to get rows from an
ADODB.Recordset and the
ADODB.Record and put them in a DataSet.

The following C# code using System.Data.OleDb namespace
will accomplish
this.

{
//Code creates an ADODB Recordset using the Northwind.mdb
database.
//You will need to change the path to point to the
database on
your system.
//You could also be using a recordset returned from
another
location or Component

ADODB.Recordset MyRs= new ADODB.Recordset();
ADODB.Connection MyCn = new ADODB.Connection();

MyCn.Open("Provider=Microsoft.Jet.OLEDB.4.0;data
source=D:\\Northwind.mdb","Admin","",0);
MyRs.Open("Select * from
Customers",MyCn,ADODB.CursorTypeEnum.adOpenStatic,
ADODB.LockTypeEnum.adLockOptimistic,0);

//Create and fill the dataset from the recordset and
populate
grid from Dataset.
OleDbDataAdapter myDA = new OleDbDataAdapter();
DataSet myDS = new DataSet("MyTable");
myDA.Fill(myDS, MyRs, "MyTable");

dataGrid1.DataSource = myDS;
dataGrid1.DataMember="MyTAble";

//Close and destroy ADODB Objects
//Note that the OleDbDataAdapter.Fill overload that takes
//a DataTable and an ADO object implicitly calls Close on
//the ADO object when the Fill operation is complete.

MyCn.Close();
}

Hope this information is helpful.


Ravikanth[MVP]

-----Original Message-----
Hi

I am using a VB6 client which connects to a web service using soap3.0
The client is querying a MSDE and filling up a ADODB.recordset. What I
am trying to acomplish is to send this recordset to the web service
where it will be inserted into another MSDE. Much like a batch job.

The client
--------------------------------------------------------- ----------------
Dim r As ADODB.Recordset
Dim xml as string
Set r = m_us.db.connection1.Execute("Select * from status") 'Get a
recordset from an ado wrapper

r.Save "c:\doit.xml", adPersistXML ' Save the recordset to disk in XML
format
xml=readXmlFromDisk()'Read the xml from disk into a string

m_service.uploadData(xml)'Use soap to send the string to the
webservice

The web service using C#
--------------------------------------------------------- -----------------
[WebMethod]
public bool uploadData(string data)
{
//How do I grab the xml string and insert the data into a table?
//My best suggestion is to convert the XML string into a dataset(don`t
know how)
//and save this dataset into the MSDE
}


Thanks

Tor Christian
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top