OLEDB Parameterized Query

Here is an example of how the parameterized queries work with CSharp, OleDB. try { connw.Open(); OleDbCommand command; command = new OleDbCommand( “Update Deliveries ” + “SET Deliveries.EmployeeID = ?, Deliveries.FIN = ?, Deliveries.TodaysOrders = ? , connw); command.Parameters.Add(new OleDbParameter(“@EMPID”, Convert.ToDecimal(empsplitIt[1]))); command.Parameters.Add(new OleDbParameter(“@FIN”, truckSplit[1].ToString())); command.Parameters.Add(new OleDbParameter(“@TodaysOrder”, “R”)); catchReturnedRows = command.ExecuteNonQuery();//Commit connw.Close(); } catch (OleDbException exception) … Read more

Reading excel file using OLEDB Data Provider

This worked for me using (OleDbConnection conn = new OleDbConnection()) { DataTable dt = new DataTable(); conn.ConnectionString = “Provider=Microsoft.ACE.OLEDB.12.0;Data Source=” + path + “;Extended Properties=”Excel 12.0 Xml;HDR=YES;IMEX=1;MAXSCANROWS=0″”; using (OleDbCommand comm = new OleDbCommand()) { comm.CommandText = “Select * from [” + sheetName + “$]”; comm.Connection = conn; using (OleDbDataAdapter da = new OleDbDataAdapter()) { da.SelectCommand … Read more

OleDbCommand parameters order and priority

According to http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbcommand.parameters.aspx OleDbCommand does not support named parameter The OLE DB .NET Provider does not support named parameters for passing parameters to an SQL statement or a stored procedure called by an OleDbCommand when CommandType is set to Text. In this case, the question mark (?) placeholder must be used. For example: SELECT * … Read more

Microsoft.ACE.OLEDB.12.0 provider is not registered

Basically, if you’re on a 64-bit machine, IIS 7 is not (by default) serving 32-bit apps, which the database engine operates on. So here is exactly what you do: 1) ensure that the 2007 database engine is installed, this can be downloaded at: http://www.microsoft.com/downloads/details.aspx?FamilyID=7554F536-8C28-4598-9B72-EF94E038C891&displaylang=en 2) open IIS7 manager, and open the Application Pools area. On … Read more