tags:

views:

273

answers:

1

Hi i am trying to update a excel file using the oledb connections. But i am getting the following error:
"No value given for one or more required parameters." This is my code:

String sConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath(@"TempUploads\" + hdnExcelName.Value) + ";Extended Properties='Excel 8.0;HDR=NO'";
    OleDbConnection objConn = new OleDbConnection(sConnectionString);
    objConn.Open();
    string sql = "update [Sheet1$] set [A8]='apple1.jpg'";
    OleDbCommand objCmdSelect = new OleDbCommand(sql, objConn);
    objCmdSelect.ExecuteNonQuery();
    objConn.Close();

thanks in advance

A: 

With HDR=No, the various columns are referred to as F1, F2, F3 etc. A8 is not suitable.

The SQL should be on the lines of:

UPDATE [Sheet1$] SET F1='apple1.jpg' 
WHERE F2='Blah'

EDIT re comment

strSQL = "SELECT f1 From [Sheet1$a8:a8]"
Remou
hi remou thanks a ton for replying to my question. I need to update the records in a particular row but i am not having any primary key column. is there a way to update a particular row on the basis of row number in excel???
pankaj
You can create a single cell recordset, I have added a note.
Remou