oledb

How to parameterize complex OleDB queries?

好久不见. 提交于 2019-11-30 20:18:58
问题 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.

OleDb Update sql with Parameter value not updating record in Access

∥☆過路亽.° 提交于 2019-11-30 19:55:24
问题 Can anybody tell what is wrong in the following code ? command.Connection = ConnectionManager.GetConnection(); command.CommandText = "Update Table1 SET Replaceme = ? WHERE Searchme = ?"; command.CommandType = CommandType.Text; command.Parameters.AddWithValue("Replaceme", "Goodman"); command.Parameters.AddWithValue("Searchme", "Anand"); command.Connection.Open(); int recordsaffected = command.ExecuteNonQuery(); MessageBox.Show("Records affected : " + recordsaffected); MessageBox shows 0

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

十年热恋 提交于 2019-11-30 17:28:23
问题 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

ASP.NET OLEDB code breaks when deployed on IIS7

ε祈祈猫儿з 提交于 2019-11-30 17:08:05
问题 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(

Mixed Data Type in Excel, IMEX Doesn't Work

自闭症网瘾萝莉.ら 提交于 2019-11-30 16:35:51
I am trying to export xls into datatable. Below is my connection string. string path = //xls source path OleDbConnection MyConnection = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; Data Source='" + path + "';Extended Properties='Excel8.0;IMEX=1;TypeGuessRows=0;HDR=No;ImportMixedTypes=Text'"); I set IMEX=1 and all the other extended properties as I have to deal with mixed datatypes. Even though I set the connection like that yet I still produced error. There are no error messages , but the inconsistent rows (who don't follow the majority datatype are set to null instead ). Can someone

Mixed Data Type in Excel, IMEX Doesn't Work

岁酱吖の 提交于 2019-11-30 16:18:44
问题 I am trying to export xls into datatable. Below is my connection string. string path = //xls source path OleDbConnection MyConnection = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; Data Source='" + path + "';Extended Properties='Excel8.0;IMEX=1;TypeGuessRows=0;HDR=No;ImportMixedTypes=Text'"); I set IMEX=1 and all the other extended properties as I have to deal with mixed datatypes. Even though I set the connection like that yet I still produced error. There are no error messages ,

Reading Excel sheet using ACE.OLEDB.12.0 with IMEX=1 not working

拥有回忆 提交于 2019-11-30 15:22:17
I'm using the below Connection String with ACE.OLEDB.12.0 to read data from an XLSX Spreadsheet, but the I set IMEX=1, it does not work while when I remove IMEX=1 completely, it works fine. "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Working Folder\ICDE\Ramsden 4.xlsx;Extended Properties=""Excel 12.0 xml;HDR=No;IMEX=1;""" Can anyone explain why? Because I had the impression that IMEX=1 reads all data as text, so it was more secure! Thanks JP IMEX= <0/1/2> IMEX refers to IMport EXport mode. This can take three possible values. IMEX=0 and IMEX=2 will result in ImportMixedTypes being

Read a big Excel document

混江龙づ霸主 提交于 2019-11-30 15:05:58
问题 I want to know what is the fastest way to read cells in Excel. I have an Excel file that contains 50000 rows and I wanna know how to read it fast. I just need to read the first column and with oledb connection it takes me like 15 seconds. Is there a faster way? Thanks 回答1: Here is a method that relies on using Microsoft.Office.Interop.Excel. Please Note: The Excel file I used had only one column with data with 50,000 entries. 1) Open the file with Excel, save it as csv, and close Excel. 2)

Linked SQL Server database giving “inconsistent metadata” error

最后都变了- 提交于 2019-11-30 13:45:54
问题 I am currently running a third-party software suite, which uses SQL Server as its database. I have a second instance of SQL Server running in a different location, and some apps that I am building in that instance SQL Server needs to access some data in the third-party software. So, I created an ODBC connection between the boxes, and set up the third-party SQL server as a linked server on my version of SQL Server. As a test, I ran something like the following statement from my SQL server,

Why doesn't Microsoft support OLE DB connections to SQL Azure?

余生颓废 提交于 2019-11-30 13:18:20
问题 At the MSDN website it says, " Connecting to SQL Azure by using OLE DB is not supported. " There are other places on the web where folks report that it works fine for them after tweaking the server name in the connection string, such as here and here. Even SQL Server's Analysis Services uses OLE DB to connect to SQL Azure! I develop a native/unmanaged application in Delphi that connects to SQL Server using ADO through the OLE DB provider for SQL Server. I'm considering adding SQL Azure