oledb

System.Data.OleDb.OleDbException: Invalid internet address. How do you connect to excel files located on a webserver using OleDb

萝らか妹 提交于 2019-12-01 02:17:46
问题 I'm trying to create an OleDb connection to an Excel file that is located on a SharePoint server. The example code I'm playing with at the moment throws an OleDb exception "Invalid internet address": public static void ConnectToRemoteExcelFile() { string connectionString = String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=\"Excel 8.0;HDR=Yes;\";", "http://horde.servername.co.uk/Docs/Documents/Sales.xlsx"); using (OleDbConnection connection = new

How to parameterize complex OleDB queries?

对着背影说爱祢 提交于 2019-12-01 01:57:11
I'm trying to refactor some code that is using strings concatenation for creating SQL commands (which makes it vulnerable for a SQL injection). Basically all I'm trying to do is to replace all the string sqlToExecute = String.Format(..) statements with a SQL command and a List of OleDB parameters. I understand how this can be done for simple cases like String.Format("Select * from myTable where id = {0}", id) . However, I could not find a set of good examples for more complex SQL queries. Here are some of the queries that I'm not sure how exactly I can parameterize: 1. Parameters are used for

Gathering data from Access database

可紊 提交于 2019-12-01 01:53:05
I want to gather some data from some tables of an Access Database, I've found some solutions online, but I haven't found ways to fill a datatable, or dataset, and get each single field properly. Is it easier for me to get whole tables then get just the info that i want, or should I make a lot of searches in the access DB getting just what i Want each time? Any code snippets for it? info: The Access Database is in an ACCDB file, with no user or password I'm currently using VB.NET, but it doesn't matter if you answer in C# --[EDIT]-- Sub question : Connecting to ACCDB format MS-ACCESS database

OPENROWSET with Excel file

限于喜欢 提交于 2019-12-01 01:30:44
I want to execute simple statement: SELECT * FROM OPENROWSET('MICROSOFT.JET.OLEDB.4.0','Text;Database=C:\Temp\;','SELECT * FROM [test.csv]') And suddenly I get this message today morning: Msg 7308, Level 16, State 1, Line 1 OLE DB provider 'MICROSOFT.JET.OLEDB.4.0' cannot be used for distributed queries because the provider is configured to run in single-threaded apartment mode. It was working till today morning! Here is my server specs: Windows 2008 R2 64 bit SQL Server 2008 64 bit I've installed AccessDatabaseEngine_x64.exe. Sql Server is running under LocalService account. I've set Everyone

Microsoft ACE OLEDB connection creating empty Excel when there are 166,110 rows

假装没事ソ 提交于 2019-12-01 01:04:28
I am programming in C# and using an oledbconnection . This is the standard connection string e.g. using (OleDbConnection conn = new OleDbConnection( "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + saveFilenameAndLocation + ";Extended Properties='Excel 12.0 Xml;HDR=Yes'" )) This works successfully and creates my Excel spreadsheet full of the correct data, when the number of rows isn't excessive. However, whenever the number of rows in the spreadsheet increases to a large size (e.g. currently it is failing on 166,110 rows), it produces an empty spreadsheet with the worksheet tab name set to

multi-sheet import with oledb netting “_xlnm#_FilterDatabase” as sheet names

本秂侑毒 提交于 2019-11-30 22:49:26
i have an excel with multi-sheets that i want to import the code is fairly simple and basic and should work but my sheetnames keep coming back as "_xlnm#_FilterDatabase" in the debugger and is the root of my prob here is the relevant portion of the code: string sheetName = ""; file = HostingEnvironment.MapPath("~/files/master1.xlsx"); xConnStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + file + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES;IMEX=1\";"; using (OleDbConnection connection = new OleDbConnection(xConnStr)) { // get sheet names connection.Open(); DataTable sheets =

Is there a better way to indicate “null” values in Excel?

那年仲夏 提交于 2019-11-30 22:13:44
I have an Excel 2007 workbook that contains tables of data that I'm importing into DataTable objects using ADO.NET. Through some experimentation, I've managed to find two different ways to indicate that a cell should be treated as "null" by ADO.NET: The cell is completely blank. The cell contains #N/A . Unfortunately, both of these are problematic: Most of my columns of data in Excel are generated via formulas, but it's not possible in Excel to generate a formula that results in a completely blank cell. And only a completely blank cell will be considered null (an empty string will not work).

Querying an Oracle database from SQL Server

好久不见. 提交于 2019-11-30 21:25:29
I have an Oracle 11g XE database that I would like to transfer into SQL Server Express 2005. At first I thought I'd just generate the tables in Oracle as SQL, manipulate the data formats, and run the query in SQL Server. This worked for small tables, but I have several tables with a few hundred thousands rows and some with millions of rows, so this solution won't work. I then created a TNS file with the following content: OracleTnsName = ( DESCRIPTION= ( ADDRESS = (PROTOCOL=TCP)(HOST=localhost)(PORT=1521) ) ( CONNECT_DATA = (SERVICE_NAME=XE) ) ) I followed instructions I found elsewhere on how

Extract OLE Object (pdf) from Access DB

此生再无相见时 提交于 2019-11-30 21:21:55
We are upgrading/converting several old Access databases to MS-SQL. Many of these databases have OLE Object fields that store PDF files. I'm looking for a way to extract these files and store them in our SQL database. I've seen similar questions that answer how you might do this with image files (jpg, bmp, gif, etc) but I haven't found a way that works with PDF. I finally got some code working for what I want it to do. The trick is determining what part is the OLE Header and removing it. Here is what is working for me (based on code found here ) public static byte[] StripOleHeader(byte[]

ASP.NET OLEDB code breaks when deployed on IIS7

拈花ヽ惹草 提交于 2019-11-30 21:01:40
I'm trying to write a simple website (ASP.NET v4), which will call Windows Search, find a specific file and return it to the user. I've put together the following as an example: it calls the Windows Search service on "remoteserver", and returns the path of "somefile.txt": OleDbConnection conn = new OleDbConnection(); conn.ConnectionString = "Provider=Search.CollatorDSO;Extended Properties='Application=Windows';"; OleDbCommand cmd = conn.CreateCommand(); cmd.CommandText = string.Format( "SELECT System.ItemPathDisplay, System.ItemType FROM " + " sytelhp.systemindex WHERE SCOPE='file:/