Updating Excel Spreadsheet Through ASP.NET

Joined
Jul 28, 2009
Messages
1
Reaction score
0
Hello Everyone,

I am encountering quite an unusual sort of problem while updating my Excel spreadsheet from an ASP.NET application. Basically I have an excel worksheet (Sheet1$) that contains contact information. Two columns are totally blank and I want to update all rows in that column with a single value. I am currently using the following code to perform this action...

Connection String:
Code:
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties=\"Excel 8.0;HDR=YES\"";

Code to Execute Query:


Code:
OleDbConnection conn = new OleDbConnection(strConn);
conn.Open();

string sql = "UPDATE [Sheet1$] SET List_Name='" + listName + "' AND Active='" + active + "'";

OleDbCommand cmd = new OleDbCommand(sql, conn);
cmd.ExecuteNonQuery();

The code itself executes just fine, but when I go back into my excel spreadsheet to see if the data has been updated, all the rows in these columns are still blank. I have attempted to fix this doing the following:

A. Checked file permissions on the directory and the file itself.
B. Added some extended properties to the connection string (ReadOnly, Mode=ReadWrite) with no change in results.
C. Tried updating a single record but the column row still remained blank.
D. Debugged to make sure the variables listName and active had values (they did)

If any of you have some insight on this please let me know. Thanks in advance.
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top