OleDb Connection to XML File

dotnet framework


  • 1. ado.net / execute reader / sp question
    Hi, I have a stored procedure which has a couple of input parameters and out parameters as below... If in C# .Net2.0 using SQL ADO.NET if I use ExecuteReader I get the results of the user table but if in the code i use cmdTest.Parameters["@Token"].Value; its always null. Basically can I use output paramaters when using Execute reader? If I use ExecuteNonQuery it works fine. Maybe I just need a bit of better explaining. All help much appreciated. Thanks Gary set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[LoginDBUser2] @Username varchar(50), @EncPassword varchar(50), @Token uniqueidentifier output, @LastLogin datetime output AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- If user exists return a new GUID token IF EXISTS (SELECT * FROM Users WHERE Username = @Username AND EncPassword = @EncPassword) BEGIN -- Get the old logon time before we update it Select @LastLogin = [LastLogin] FROM Users Where Username = @Username AND EncPassword = @EncPassword UPDATE Users SET [LastLogin] = getdate() WHERE (Username = @Username AND EncPassword = @EncPassword) --Get a New ID SET @Token = NewID() --Return all the Users Details SELECT * FROM Users WHERE Username = @Username AND EncPassword = @EncPassword END ELSE BEGIN SET @Token = null END END
  • 2. Strongly DataSet with multiple DataTables filled?
    .NET 2.0 VS 2005 I've got a remote database behind a firewall, I need to create a web service that returns a dataset populated with multiple DataTables (so I don't have to make several expensive soap calls). I have no control over the database schema, so I have to work with it as is. I have several tables: one master table, and several detail tables that are linked to the master, some with one-to-many relationships, some are one-to-one. I also have a table unrelated to any of the rest of the data. I created a stronly typed dataset that has all the tables defined in it, along with Get and Fill functions that take parameters (the master and unrlated table take date parameters to return all rows on a certain date, while the detail tables take master id number and return all rows that have id's that are in the master table). I want to fill all the datatables with the appropriate data, then return that dataset from the web method. I'm kind of at a loss to figure out how to approach this. How do I fill all the datables in the dataset with the appropriate data so that I can return it all at once? Any suggestions?
  • 3. ExecuteReader question
    Hi, Im using c# and sql 2005 to retrieve data. What im trying to do is... 1) Connect to webservice 2) Open DB connection 3) Read & return 100 records 4) Do some process 5) Reconnect to webservcice 6) start now at record (currently 101) 7) Read & return 100 records 8) Loop 4 I dont wish to use data sets, but i was wondering if there is a way in say T-SQL etc that you perform a SELECT statement to say just get 100 records a time but starting at record X. At the moment im calling Read(); on the SqlDataReader x times then when i get to start record i want, start pulling the fields out. Is this the quickest way? is there an alternative? Mamy Thanks Gary
  • 4. no value given for one or more parameters
    Hi, I know there are a couple of other posts regarding this matter, but I am using the simplest of statements, yet the get the above error. My code looks like this: OleDbCommand cmd = new OleDbCommand ("SELECT Name FROM Employees", Conn); conn.Open(); OleDbDataReader dr = cmd.ExecuteReader(); It falls over on the ExecuteReader with the above error (I have the actual code in a try catch block, calling the Read method of dr). As I am not specifying any parameters, can anyone tell me what the problem might be?
  • 5. Timeout - max pool size reached
    I got the following message on my Sql Server 2000: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. I understand what this is when dealing with Web Application. But this problem is a small program that just opens and closes an sql table. It is running as a service and not part of a web application. Why would I get this message? Thanks, Tom

OleDb Connection to XML File

Postby SmFzb24gQmFybmV0dA » Wed, 03 Dec 2008 08:19:01 GMT

I would like to create an OleDb connection to an XML File, but I cannot find 
information about the connection string parameters.  Is this possible?

I've got some parameters that an application uses and I have decided that it 
would be best to store it in a database-like storage area.  I figured I could 
store the values in a CSV, XLS, or MDB file and maintain the parameters 
through a OleDb connection.  However, I wondered if I could use XML as well.  
I don't want to rely on a server connection and I don't want to load anything 
on the client.

For what it's worth, I'm using VS2005.

Re: OleDb Connection to XML File

Postby Patrice » Fri, 05 Dec 2008 02:17:29 GMT

The main problem is likely to write...

Another option would be to just use a dataset (that can be loaded/stored to 
an xml file). Note though that this is likely valid if you don't have to 
much data as it was never intended to be a replacement for databases...

Or perhaps the good old Xml API (or the LINQ to XML flavor) would be enough 
(not sure what you want from that extra layer ?).

Also you have checked the config file option and for some reason decided not 
to use this option ? (AFAIK you can also refer to antoher file from a config 
file if you just want to keep this separate from your main config file).

As always it's better to give some details about what you are trying to do 
(the kind and the number of settings you are trying to save would likely 
help to raise better suggestion).

"Jason Barnett" < XXXX@XXXXX.COM > a 閏rit dans le 
message de groupe de discussion : 

Re: OleDb Connection to XML File

Postby SmFzb24gQmFybmV0dA » Sat, 06 Dec 2008 01:05:01 GMT

I've built an assembly that processes "Job" objects.  A Job object stores 
information about an automated task.  This Job object could have a collection 
of parameters that are needed to run, and those parameters are fed by the 
executing assembly.  The executing assembly I'm currently developing is a 
Singleton-like web service designed to run a collection of Job objects.  I'm 
trying to design it so that it has little or no knowledge of the Job objects.

With that in mind, I don't believe storing values in a config file will work 
because 1) the web.config file does not allow you to save AppSettings, and 2) 
the executing assembly must know about the parameters it's loading (it must 
be recompiled each time a parameter is added).

I've thought of storing the parameters in a local data source (a flat-file 
of some sort), which the executing assembly could load.  The data source 
would store the Job identifier, the parameter identifiers and values, and a 
simple Update statement for updating the parameter values after a job is 
complete.  Other approaches I'm considering is storing a snippet of code that 
the executing assembly would have to process (not sure if that's feasible), 
or writting Jobs as assemblies that the executing assembly dynamically loads 
based on a common interface found with Reflection.

Bottom line... I'm exploring my options and wondering how (if possible) to 
connect to an XML file with OLE DB.

Re: OleDb Connection to XML File

Postby sloan » Wed, 10 Dec 2008 06:10:38 GMT

I would code up a strong dataset, and use that. (as previously mentioned).

Be careful if you have multiple threads reading/writing data.

The DataSet.WriteXml() an DataSet.GetXml() ....... it doesn't get much
easier than that.

I do this for small config data stuff all the time.

EMPHASIS on the "small".

"Jason Barnett" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...

Similar Threads:

1.Getting XML via an OLEDB connection

Hi all.

I've a problem trying to get XML from SQL Server via an OleDb

More precisely, the code does not work if the stored have the "FOR XML"
clause, otherwise works fine.

As you can see from the code, after the ExecuteReader, row by row
(while reading), I put the object array representing the fields into an
array of object.

The array will be parsed to return data back to the client in some
other format. As said, this code works fine if the stored are
"regular". When a stored returns XML (in UTF-16 Encoding) I'm able to
get the byte[] from the datareader into the usual object[], but I'm not
able to convert that byte array into the corresponding string. The
conversion does not work for UTF-16, UTF-8, ....

Any idea about that?

thanks and ciao

Well, this is the code I'm using to get the data is:

            OleDbConnection _DB = new OleDbConnection();
            _DB.ConnectionString =  strConnString;
            OleDbCommand cmd = new OleDbCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText ="sp_FORXML";
            cmd.Connection = _DB;

          //...  add parameter here [...omissis...]

                OleDbDataReader dr;
                dr = cmd.ExecuteReader(cb);
                int arrayindex;
                arrayindex = 0;

                 while (dr.Read())
                        Row r = new Row();
                        object[] vals = new object[dr.FieldCount];
                        r._Fields = vals;
                        values.Insert(arrayindex++, r);

            Row[] aRowToRet = new Row[values.Count];
            return aRowToRet;

2.Problem opening oledb connection to excel file

3.Bulk Import using Text file as input (OLEdb connection)

4.There must be a better way than this (oledb connections and connection strings)

Hi all,

I'm currently writing a windows-forms based application in C# using
visual studio express.  It interfaces with an Access Database backend
and at the moment, I have a seperate connection for every function
(such as a button click) that I use.  This means that at the moment, my
program is doing the following in a number of places:

1) On Form_Load, read the list of users from the database then close
the data connection
2) When the button is pushed to get the details of a specific user,
open the data connection (respecifying the variables including the
connection string), select the data and then close the connection

I'm from a PHP development background, so what I would like to do is

1) Declare an application wide database connection object.
2) when any form is loaded, open the database object, do what you have
to do and close the connection.
3) if a button is clicked, open the same database object, do what you
need to do and close the object.

In the past (using PHP), I've declared the variable/object at the start
of the session and then just opened and closed it as needed.  How do I
do this in C#?



5.OleDb connection to SQL connection


I have an OleDb connection string to an SQL server provided by the Data Line
Properties dialog.  What do I need to do to convert this OleDb connection to
an SQL connection.

Can I just remove the Provider property?

-Sam Matzen

6. Workgroup file information file error: OleDB to Access file

7. ADOMD.NET : connection string without xmla - No connection could b

8. ADOMD.NET : connection string without xmla - No connection cou

Return to dotnet framework


Who is online

Users browsing this forum: No registered users and 67 guest