cmd.CommandText = "Insert Into [Target$] Values ('1', 'Ping', '800-888-8888')";
-----Original Message----- From: yan ping [mailto:[EMAIL PROTECTED] Sent: Sunday, June 15, 2003 6:52 PM To: [EMAIL PROTECTED] Subject: [ADVANCED-DOTNET] ERROR [HY000] [Microsoft][ODBC Excel Driver] Operation must use an updateable qu Hi all, I have a very simple Excel 2002 file called "Target.xls". The file has just 1 worksheet called "Target". Inside the worksheet, I have defined 3 columns whose headers are in turn called "TargetId, "TargetName" and "TargetPhone". I am just trying to insert one row into the Excel file using Odbc.Net Driver. BTW, I am using .NET Framework 1.0, but I don't think it matters. Below is my code: string strConnection = @"Driver={Microsoft Excel Driver (*.xls)};DBQ=C:\Target.xls"; OdbcConnection conn = new OdbcConnection(strConnection); try { conn.Open(); OdbcCommand cmd = conn.CreateCommand(); cmd.CommandText = "Insert Into [Target$] Values ('1, 'Ping, '800-888-8888)"; cmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { if (conn.State == ConnectionState.Open) conn.Close(); } It always throws an exception saying "ERROR [HY000] [Microsoft][ODBC Excel Driver] Operation must use an updateable query.". I am stuck and very confused. Where am I wrong??? Any helps are greatly appreciated. Best regards, Ping _________________________________________________________________ Help STOP SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail