Ping,
This could just be from the reproduction of the source code, but the line for the
VALUES clause in your example appears to contain unterminated string constants:
('1, 'Ping, '800-888-8888)";
If it does look like this in your actual code, then it would cause a problem and might
be your error source. Are you stepping through in debug and is the error occuring when
you execute "cmd.ExecuteNonQuery();"?
Try putting an end single-quote (') following each value in the VALUES clause and see
what happens. Hope this helps.
Mike
-----Original Message-----
From: yan ping [mailto:[EMAIL PROTECTED]
Sent: Sun 6/15/2003 6:51 PM
To: [EMAIL PROTECTED]
Cc:
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