Showing posts with label types. Show all posts
Showing posts with label types. Show all posts

Tuesday, March 6, 2012

AdomdConnection via a UDL file

To connect to a database engine by using types such as OleDbConnection, I can create a UDL file to connect to the database, then just use that UDL file by a connection string like "File Name = \\My Documents\\my.udl".

It seems that I cannot use this way to connect to SSAS. I can create a UDL file to connect to a local SSAS without any problem. However, when I use connection string like "File Name = \\My Documents\\myssas.udl" for AdomdConnection, I get the following error:

"The 'File Name' property name is not formatted correctly."

Could anyone tell me what is the correct format?

Thanks,

hz

hello,

right now supplying conneciton information for an AdomdConnection in a UDL file is not supported in Adomd.Net.

hope this clarifies.

|||

Thanks, Mary.

It is good to have this confirmed.

hz

Friday, February 24, 2012

ADO.NET OleDb SET ROWCOUNT or DBPROP_MAXROWS

I am writing a data access tool that needs to be non provider specific. I have used System.Data.OleDb to access a variety of data source types (MSSQLServer, MSAccess, MSExcel, CSV, Oracle, XML). This works beautifully. Thankyou Microsoft for giving us ADO.NET2.0.

However, I now need to restrict the number of rows returned from a SELECT statement. Is there any way I can I achieve this in a non provider specific fashion?

So far searches have yielded DBPROP_MAXROWS however I can find no way of setting the DBProperties using ADO.NET2.0. Is this possible?

Documentation for DBPROP_MAXROWS states that it uses "SET ROWCOUNT n" as part of the command text. I tried this and it works but not for the JET4 provider (this is a problem since I use JET4 to access .mdb, .xls and .csv files)!

Any tips here would be greatly appreciated. Even if somebody were to tell me that it's just not possible, at least that would put me out of my misery :)

Thanks.

Because of the way JET accesses data, bringing all of the data to the client before processing the criteria, I don't think that there is a way to make that work.|||

Thanks for the reply Arnie,

since posting I have done some more research and discovered that using TOP works for Jet. This is good for me as it also works for SQL Server. The approach I have taken is as follows:

int maxRows = 100;

string someQry = "SELECT * FROM table1";

string topQry = "SELECT TOP " + maxRows.ToString() + " * FROM (" + someQry + ") as topSubQry";

However it doesn't work for XML files. To get data from XML files I use a connection string of "Provider=MSDAOSP.1;Data Source=MSXML2.DSOControl.2.6;" and then the full path to the XML file as the command text. I am guessing there will just be no way to limit the rows returned when using this provider.