473,396 Members | 1,995 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 13591
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Adam Short | last post by:
I am trying to write a routine that will connect a .NET server with a classic ASP server. I know the following code doesn't work! The data is being returned as a dataset, however ASP does not...
2
by: Ed Staffin | last post by:
Hi, I have a need to conver the xml produced by a .net dataset (with a single table) into an adodb.recordset. The adodb.recordset doesn't understand the xml that the dataset.GetXml method...
5
by: jk | last post by:
I'm having trouble converting a datatable into xml, with resonse.write to aspx. I'm basically converting vb code that saved a recordset into a stream into c#, but the format is wrong. I've tried...
29
by: Mark B | last post by:
We have an Access app (quite big) at www.orbisoft.com/download. We have had requests by potential users to have it converted to an SQL version for them since there corporate policy excludes them...
4
by: lakshmi | last post by:
Hi all, My requirement is I need to have three different recordsets open at the same time. Traversing through the 3 recordsets, I would check on the data and based on some rules, return an object...
0
by: Thaddeus | last post by:
//Author: //Thaddeus Jacobs, MCP //Kinematic Automation, Inc. //mailto:tjacobs@kinematic.com // //Description: //convert ADO .NET dataset to ADO 2.5 2.6 2.7 recordset and v/v //DataSet to...
9
by: B. Salmon | last post by:
I have a Visual C++ .NET function that is calling an unmanaged function that returns an ADO _Recordset* object. I want to be able to convert that into an ADO.NET DataSet (or DataTable). I tried...
2
by: Patreek | last post by:
Hi, I'm writing my first real asp.net app at my job, and I'd like opinions please. In my classic ASP apps that I've written, I'd often have separate files for retreiving data and returning the...
6
by: James | last post by:
I am writing a web service for a classic ASP application. I need to consume an ADO recordset and then send it to another web service for processing. I found an MSDN ariticle telling how to do this...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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,...

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.