473,806 Members | 2,661 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:\fil es\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:\fil es\xslfile.xsl" , object ActiveConnectio n,
ADODB.CursorTyp eEnum, ADODB.LockTypeE num, 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 13635
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:\fil es\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:\fil es\xslfile.xsl" , object ActiveConnectio n,
ADODB.CursorTyp eEnum, ADODB.LockTypeE num, 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=Micro soft.Jet.OLEDB. 4.0;";
strConnection += " Data Source=";
strConnection += this.m_strDBNam e;
strConnection += ";";

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

adCON.Open(strC onnection, "", "", 0);
adRS.Open(strQu ery, adCON, ADODB.CursorTyp eEnum.adOpenKey set,
ADODB.LockTypeE num.adLockOptim istic ,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:\fil es\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:\fil es\xslfile.xsl" , object ActiveConnectio n,
ADODB.CursorTyp eEnum, ADODB.LockTypeE num, 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=Micro soft.Jet.OLEDB. 4.0;";
strConnection += " Data Source=";
strConnection += this.m_strDBNam e;
strConnection += ";";

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

adCON.Open(strC onnection, "", "", 0);
adRS.Open(strQu ery, adCON, ADODB.CursorTyp eEnum.adOpenKey set,
ADODB.LockTypeE num.adLockOptim istic ,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.Connectio n.

--
Lasse Vågsæther Karlsen
http://www.vkarlsen.no/
mailto:la***@vk arlsen.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:\Fil es\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.Connectio n.

--
Lasse Vågsæther Karlsen
http://www.vkarlsen.no/
mailto:la***@vk arlsen.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"\Fil es\MyXslFile.xs l")

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

rs.Open("C:\fil es\xslfile.xsl" , object ActiveConnectio n,
ADODB.CursorTyp eEnum, ADODB.LockTypeE num, 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.Reflecti on.Missing.Valu e;

Hope this helps.

Barry
in Oregon

"Robert" <rh******@hotma il.com> wrote in message
news:96******** *************** ***********@mic rosoft.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"\Fil es\MyXslFile.xs l")

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

rs.Open("C:\fil es\xslfile.xsl" , object ActiveConnectio n,
ADODB.CursorTyp eEnum, ADODB.LockTypeE num, 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
9333
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 recognise datasets and requires a recordset. Can the datatypes be converted? At the Classic ASP end or .NET end? Can SOAP toolkit provide the conversion, can any toolkit provide a conversion? ...
2
4963
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 produces. Can someone point me in the right direction? Thanks ... Ed
5
52693
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 using streams, datadoc, xmlreader, etc with no success. I need to convert it directly to a string or via a stream, but not in a file. Here's some sample code that gives me the bad format. I'll post the good format below that give me rowsets rather...
29
3714
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 from buying mdb backends. Here's the (million dollar?) questions :) How long and how difficult a process would it be? Which SQL platform would we be best to develop it on?
4
9465
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 from my function. Will it be efficient to use a SQLDataReader or a DataSet for this situation? I understand from the documentation that there can be only one SQLDataReader associated with a connection open at a time. So, it seems like I can't...
0
10279
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 recordset conversion. //Get RecordSet from Dataset //ds2rs DataSet2RecordSet
9
6843
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 to use the OleDbDataAdapter.Fill method, but I could only get that to work if I gave it an ADODB::RecordsetClass object. I couldn't figure out how to get an ADO _Recordset into an ADODB::RecordsetClass. Any ideas? I don't want to have to...
2
1733
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 data to other pages that would call it. I'd return the data as arrays so that I wouldn't have to have my DB connections open all the time while the pages ran. Now in .net, it seems like I have to choose between using a SQldatareader or a...
6
10836
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 (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconfillingdatasetwithadorecordset.asp), one big problem - it says to import ADOComponent.dll and msado15.dll. I found msado15.dll but I can't find ADOComponenet.dll,...
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9597
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10369
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10110
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5682
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4329
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.