Connecting Tech Pros Worldwide Forums | Help | Site Map

Convert Dataset to Recordset in C#

Marathoner
Guest
 
Posts: n/a
#1: Nov 16 '05
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

Jeff Gaines
Guest
 
Posts: n/a
#2: Nov 16 '05

re: Convert Dataset to Recordset in C#


On 30/12/2004 Marathoner wrote:
[color=blue]
> 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[/color]

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
Marathoner
Guest
 
Posts: n/a
#3: Nov 16 '05

re: Convert Dataset to Recordset in C#


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:
[color=blue]
> On 30/12/2004 Marathoner wrote:
>[color=green]
> > 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[/color]
>
> 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
>[/color]
Lasse Vågsæther Karlsen
Guest
 
Posts: n/a
#4: Nov 16 '05

re: Convert Dataset to Recordset in C#


Marathoner wrote:[color=blue]
> Thanks for the reply.
>
> I am opening a recordset from a xsl file, not a database. How would you do
> that in C#?[/color]
<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/
mailto:lasse@vkarlsen.no
PGP KeyID: 0x0270466B
Robert
Guest
 
Posts: n/a
#5: Nov 16 '05

re: Convert Dataset to Recordset in C#


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:
[color=blue]
> Marathoner wrote:[color=green]
> > Thanks for the reply.
> >
> > I am opening a recordset from a xsl file, not a database. How would you do
> > that in C#?[/color]
> <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/
> mailto:lasse@vkarlsen.no
> PGP KeyID: 0x0270466B
>[/color]
Jeff Gaines
Guest
 
Posts: n/a
#6: Nov 16 '05

re: Convert Dataset to Recordset in C#


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

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
Robert
Guest
 
Posts: n/a
#7: Nov 16 '05

re: Convert Dataset to Recordset in C#


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:
[color=blue]
> On 30/12/2004 Marathoner wrote:
>[color=green]
> > Thanks for the reply.
> >
> > I am opening a recordset from a xsl file, not a database. How would
> > you do that in C#?
> >
> > Robert[/color]
>
> 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
>[/color]
Jeff Gaines
Guest
 
Posts: n/a
#8: Nov 16 '05

re: Convert Dataset to Recordset in C#


On 30/12/2004 Robert wrote:
[color=blue]
> 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[/color]

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
Robert
Guest
 
Posts: n/a
#9: Nov 16 '05

re: Convert Dataset to Recordset in C#


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:
[color=blue]
> On 30/12/2004 Robert wrote:
>[color=green]
> > 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[/color]
>
> 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
>[/color]
BBFrost
Guest
 
Posts: n/a
#10: Nov 16 '05

re: Convert Dataset to Recordset in C#


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" <rhill938@hotmail.com> wrote in message
news:964C9917-B850-45E6-A6A6-C841DA4AC695@microsoft.com...[color=blue]
> 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[/color]
part[color=blue]
> of this process, I create a .xsl file which comtains both the schema and[/color]
the[color=blue]
> data. I need to open the recordset with this .xsl file. VB.NET is like[/color]
this:[color=blue]
>
> 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:
>[color=green]
> > On 30/12/2004 Robert wrote:
> >[color=darkred]
> > > 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[/color]
> >
> > 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
> >[/color][/color]


Closed Thread