views:

36

answers:

2

I want to update specific row of excel sheet from my asp.net application. I m able to read excel, but how can i update the records.Can i write Update query . How . please send me code:

        string strQuery = "UPDATE [Sheet1$]  SET Child Name=" + "\"" + strDataToUpdate[0] + "\",";
        strQuery = strQuery + "Pickup Point Name=" + "\"" + strDataToUpdate[1] + "\",";
        strQuery = strQuery + "Pickup Bus No=" + "\"" + strDataToUpdate[2] + "\",";
        strQuery = strQuery + "Pickup Bus Time=" + "\"" + strDataToUpdate[3] + "\",";
        strQuery = strQuery + "Drop Down Point Name=" + "\"" + strDataToUpdate[4] + "\",";
        strQuery = strQuery + "Drop Bus No=" + "\"" + strDataToUpdate[5] + "\",";
        strQuery = strQuery + "Drop Down Bus Time=" + "\"" + strDataToUpdate[6] + "\",";
        strQuery = strQuery + "Parent Name=" + "\"" + strDataToUpdate[7] + "\",";
        strQuery = strQuery + "Mobile 1=" + "\"" + strDataToUpdate[8] + "\",";
        strQuery = strQuery + "Mobile 2=" + "\"" + strDataToUpdate[9] + "\",";
        strQuery = strQuery + "Email ID 1=" + "\"" + strDataToUpdate[10] + "\",";
        strQuery = strQuery + "Email ID 2=" + "\"" + strDataToUpdate[11] + "\",";
        strQuery = strQuery + "Service Mode=" + "\"" + strDataToUpdate[12] + "\",";
        strQuery = strQuery + "WHERE Child Id=" + strDataToUpdate[13];

This Query i am using giving Syntax error.Please guide

+2  A: 

you can use it through ADO.NET. This is explained here

Adeel
Good link u had forwarded, I followed it but Adeel I make the connection with ODBC . So can u send me regards of same.Actually I can't change my existing code, so hope u understatnd. Please it is too urgent. I need proper syntax for Update Query on excel sheet through c#.
Lalit
Adeel I tried link , but getting error :ERROR [07002] [Microsoft][ODBC Excel Driver] Too few parameters. Expected 1.
Lalit
A: 

SpreadsheetGear for .NET can do it.

You can see live ASP.NET samples with C# and VB source code here and download the free trial here if you want to try it yourself.

Disclaimer: I own SpreadsheetGear LLC

Joe Erickson
nice links , thanks...
Lalit