469,953 Members | 2,229 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,953 developers. It's quick & easy.

Convert Dataset to Recordset in C#

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
Nov 16 '05 #1
9 13421
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
Nov 16 '05 #2
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

Nov 16 '05 #3
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/
mailto:la***@vkarlsen.no
PGP KeyID: 0x0270466B
Nov 16 '05 #4
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/
mailto:la***@vkarlsen.no
PGP KeyID: 0x0270466B

Nov 16 '05 #5
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
Nov 16 '05 #6
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

Nov 16 '05 #7
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
Nov 16 '05 #8
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

Nov 16 '05 #9
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" <rh******@hotmail.com> wrote in message
news:96**********************************@microsof t.com...
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

Nov 16 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by jk | last post: by
4 posts views Thread by lakshmi | last post: by
reply views Thread by Thaddeus | last post: by
9 posts views Thread by B. Salmon | last post: by
2 posts views Thread by Patreek | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.