PC Review


Reply
Thread Tools Rate Thread

Convert Dataset to Recordset in C#

 
 
=?Utf-8?B?TWFyYXRob25lcg==?=
Guest
Posts: n/a
 
      30th Dec 2004
I am trying to convert a dataset to an ADODB.Recordset. I create the sxl
file and open it in VB.NET by using:
Dim rs as ADODB.Recordset
rs.Open("C:\files\xslfile.xsl")

I want to do this same thing in C#. The open method in C# takes several
additional parameters in addition to the xsl file:
rs.Open("C:\files\xslfile.xsl", object ActiveConnection,
ADODB.CursorTypeEnum, ADODB.LockTypeEnum, int Options)

While it may seem very obvious to everyone, I am having trouble providing
valid arguments to make this method work.

Any help is greatly appreciated.

Robert
--
Robert Hill
Senior Programmer/Analyst
Wake Forest Univ Baptist Med Ctr
 
Reply With Quote
 
 
 
 
Jeff Gaines
Guest
Posts: n/a
 
      30th Dec 2004
On 30/12/2004 Marathoner wrote:

> I am trying to convert a dataset to an ADODB.Recordset. I create the
> sxl file and open it in VB.NET by using:
> Dim rs as ADODB.Recordset
> rs.Open("C:\files\xslfile.xsl")
>
> I want to do this same thing in C#. The open method in C# takes
> several additional parameters in addition to the xsl file:
> rs.Open("C:\files\xslfile.xsl", object ActiveConnection,
> ADODB.CursorTypeEnum, ADODB.LockTypeEnum, int Options)
>
> While it may seem very obvious to everyone, I am having trouble
> providing valid arguments to make this method work.
>
> Any help is greatly appreciated.
>
> Robert


Hi Robert.

This is how I use an Access database:

string strConnection;
string strQuery;

strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;";
strConnection += " Data Source=";
strConnection += this.m_strDBName;
strConnection += ";";

strQuery = "SELECT * FROM " + this.m_strTableName + " WHERE blnCompany
= True";

adCON.Open(strConnection, "", "", 0);
adRS.Open(strQuery, adCON, ADODB.CursorTypeEnum.adOpenKeyset,
ADODB.LockTypeEnum.adLockOptimistic ,0);

Can you pick the bones from that?

--
Jeff Gaines
Posted with XanaNews 1.17.1.2 http://www.wilsonc.demon.co.uk/delphi.htm
 
Reply With Quote
 
=?Utf-8?B?TWFyYXRob25lcg==?=
Guest
Posts: n/a
 
      30th Dec 2004
Thanks for the reply.

I am opening a recordset from a xsl file, not a database. How would you do
that in C#?

Robert

"Jeff Gaines" wrote:

> On 30/12/2004 Marathoner wrote:
>
> > I am trying to convert a dataset to an ADODB.Recordset. I create the
> > sxl file and open it in VB.NET by using:
> > Dim rs as ADODB.Recordset
> > rs.Open("C:\files\xslfile.xsl")
> >
> > I want to do this same thing in C#. The open method in C# takes
> > several additional parameters in addition to the xsl file:
> > rs.Open("C:\files\xslfile.xsl", object ActiveConnection,
> > ADODB.CursorTypeEnum, ADODB.LockTypeEnum, int Options)
> >
> > While it may seem very obvious to everyone, I am having trouble
> > providing valid arguments to make this method work.
> >
> > Any help is greatly appreciated.
> >
> > Robert

>
> Hi Robert.
>
> This is how I use an Access database:
>
> string strConnection;
> string strQuery;
>
> strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;";
> strConnection += " Data Source=";
> strConnection += this.m_strDBName;
> strConnection += ";";
>
> strQuery = "SELECT * FROM " + this.m_strTableName + " WHERE blnCompany
> = True";
>
> adCON.Open(strConnection, "", "", 0);
> adRS.Open(strQuery, adCON, ADODB.CursorTypeEnum.adOpenKeyset,
> ADODB.LockTypeEnum.adLockOptimistic ,0);
>
> Can you pick the bones from that?
>
> --
> Jeff Gaines
> Posted with XanaNews 1.17.1.2 http://www.wilsonc.demon.co.uk/delphi.htm
>

 
Reply With Quote
 
=?UTF-8?B?TGFzc2UgVsOlZ3PDpnRoZXIgS2FybHNlbg==?=
Guest
Posts: n/a
 
      30th Dec 2004
Marathoner wrote:
> Thanks for the reply.
>
> I am opening a recordset from a xsl file, not a database. How would you do
> that in C#?

<snip>

Why not use the OleDb .net classes ?

You can use the same provider as you would for ADODB.Connection.

--
Lasse Vågsæther Karlsen
http://www.vkarlsen.no/
private.php?do=newpm&u=
PGP KeyID: 0x0270466B
 
Reply With Quote
 
=?Utf-8?B?Um9iZXJ0?=
Guest
Posts: n/a
 
      30th Dec 2004
Thanks.
I must not understand recorsets and xml. In VB.NET I can open a recordset by:
rs.Open("C:\Files\MyXsl.xsl")
I have written this applicaton in C# and the addional arguments are
required. I do not need a connection. I have a xsl file created from a
dataset. I just need to populate the recordset with this data.
If I can't get this resolved, I may have to rewrite this in VB.NET even
though I want to continue my learning exprience in C#.

Robert


"Lasse Vågsæther Karlsen" wrote:

> Marathoner wrote:
> > Thanks for the reply.
> >
> > I am opening a recordset from a xsl file, not a database. How would you do
> > that in C#?

> <snip>
>
> Why not use the OleDb .net classes ?
>
> You can use the same provider as you would for ADODB.Connection.
>
> --
> Lasse Vågsæther Karlsen
> http://www.vkarlsen.no/
> private.php?do=newpm&u=
> PGP KeyID: 0x0270466B
>

 
Reply With Quote
 
Jeff Gaines
Guest
Posts: n/a
 
      30th Dec 2004
On 30/12/2004 Marathoner wrote:

> Thanks for the reply.
>
> I am opening a recordset from a xsl file, not a database. How would
> you do that in C#?
>
> Robert


I wouldn't, I would convert the Excel file into an Access database
since in my view it's a better way to keep data.

A quick look at help shows a subject 'Excel, Importing Data' which may
help, it seems quite similar with an additional step to select the
correct worksheet.

--
Jeff Gaines
Posted with XanaNews 1.17.1.2 http://www.wilsonc.demon.co.uk/delphi.htm
 
Reply With Quote
 
=?Utf-8?B?Um9iZXJ0?=
Guest
Posts: n/a
 
      30th Dec 2004
I agree if I were using Excel .xls files. This is a .xsl file which is an
ADO Recordset format for defining the schema.

Robert

"Jeff Gaines" wrote:

> On 30/12/2004 Marathoner wrote:
>
> > Thanks for the reply.
> >
> > I am opening a recordset from a xsl file, not a database. How would
> > you do that in C#?
> >
> > Robert

>
> I wouldn't, I would convert the Excel file into an Access database
> since in my view it's a better way to keep data.
>
> A quick look at help shows a subject 'Excel, Importing Data' which may
> help, it seems quite similar with an additional step to select the
> correct worksheet.
>
> --
> Jeff Gaines
> Posted with XanaNews 1.17.1.2 http://www.wilsonc.demon.co.uk/delphi.htm
>

 
Reply With Quote
 
Jeff Gaines
Guest
Posts: n/a
 
      30th Dec 2004
On 30/12/2004 Robert wrote:

> I agree if I were using Excel .xls files. This is a .xsl file which
> is an ADO Recordset format for defining the schema.
>
> Robert


Sorry, must have Excel on my mind :-)

The example I gave included the extra parameters, did you try them?

--
Jeff Gaines
Posted with XanaNews 1.17.1.2 http://www.wilsonc.demon.co.uk/delphi.htm
 
Reply With Quote
 
=?Utf-8?B?Um9iZXJ0?=
Guest
Posts: n/a
 
      30th Dec 2004
No. I have the data. I do not need to open a recordset and obtaion data
from a database. The data is coming form the dataset passed into the
procedure. I am creating a recordset from the data in the dataset. As part
of this process, I create a .xsl file which comtains both the schema and the
data. I need to open the recordset with this .xsl file. VB.NET is like this:

rs.Open("C"\Files\MyXslFile.xsl")

I want to do it in C# which is like this:

rs.Open("C:\files\xslfile.xsl", object ActiveConnection,
ADODB.CursorTypeEnum, ADODB.LockTypeEnum, int Options)

Since I do not need a connection, cursor type, lock type, or any options,
how is this accomplished?




"Jeff Gaines" wrote:

> On 30/12/2004 Robert wrote:
>
> > I agree if I were using Excel .xls files. This is a .xsl file which
> > is an ADO Recordset format for defining the schema.
> >
> > Robert

>
> Sorry, must have Excel on my mind :-)
>
> The example I gave included the extra parameters, did you try them?
>
> --
> Jeff Gaines
> Posted with XanaNews 1.17.1.2 http://www.wilsonc.demon.co.uk/delphi.htm
>

 
Reply With Quote
 
BBFrost
Guest
Posts: n/a
 
      30th Dec 2004
Robert,

One of the major differences between VB.Net and C#.Net that causes problems
with interop and things like you're trying to do is that there are no
optional parameters in C#.

As a result you must supply a value for all parameter values of a method or
class call.

With interop I've used oMissingValue as defined below for parameters that
don't require actual values.

object oMissingValue = Type.Missing; &
object oMissingValue = System.Reflection.Missing.Value;

Hope this helps.

Barry
in Oregon

"Robert" <(E-Mail Removed)> wrote in message
news:964C9917-B850-45E6-A6A6-(E-Mail Removed)...
> No. I have the data. I do not need to open a recordset and obtaion data
> from a database. The data is coming form the dataset passed into the
> procedure. I am creating a recordset from the data in the dataset. As

part
> of this process, I create a .xsl file which comtains both the schema and

the
> data. I need to open the recordset with this .xsl file. VB.NET is like

this:
>
> rs.Open("C"\Files\MyXslFile.xsl")
>
> I want to do it in C# which is like this:
>
> rs.Open("C:\files\xslfile.xsl", object ActiveConnection,
> ADODB.CursorTypeEnum, ADODB.LockTypeEnum, int Options)
>
> Since I do not need a connection, cursor type, lock type, or any options,
> how is this accomplished?
>
>
>
>
> "Jeff Gaines" wrote:
>
> > On 30/12/2004 Robert wrote:
> >
> > > I agree if I were using Excel .xls files. This is a .xsl file which
> > > is an ADO Recordset format for defining the schema.
> > >
> > > Robert

> >
> > Sorry, must have Excel on my mind :-)
> >
> > The example I gave included the extra parameters, did you try them?
> >
> > --
> > Jeff Gaines
> > Posted with XanaNews 1.17.1.2 http://www.wilsonc.demon.co.uk/delphi.htm
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to convert an ado recordset xml format to an ado.net dataset xml afsheen Microsoft ADO .NET 1 17th Mar 2004 12:04 PM
convert recordset to dataset Thaddeus Microsoft C# .NET 0 17th Dec 2003 10:30 PM
How can I convert an ADO.Net Dataset into a Classic ADO Recordset? Phil Agee Microsoft ADO .NET 4 2nd Dec 2003 04:22 PM
Convert ADODB recordset into .Net dataset Tor Christian Microsoft ADO .NET 2 19th Sep 2003 02:37 PM
Convert Dataset to ADODB.Recordset luis ugaz Microsoft ADO .NET 0 15th Sep 2003 04:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:43 AM.