Operation must use an updateable query... while trying to write toExcel file

D

DAXU

Hi,

I already searched old posts, but still confused.
I am a asp.net application and user "everyone" does have write and
read right to the excel file
public static readonly string sConnectionString1 =
"Provider=Microsoft.ACE.OLEDB.12.0;" + "Extended Properties=\"Excel
12.0;HDR=No; IMEX=1\"; Data Source= 1.xlsx";

My code is
DbProviderFactory factory =
DbProviderFactories.GetFactory("System.Data.OleDb");
using (DbConnection conn = factory.CreateConnection())
{
conn.ConnectionString = this.ConnString;

conn.Open();
using (DbCommand command = conn.CreateCommand())
{
command.CommandText = "SELECT * FROM [HP
Calculator APR$E4:E6]";
//reading is ok
using (DbDataReader dr =
command.ExecuteReader())
{
while (dr.Read())
{
string hello = dr[0].ToString();
}
}

//insert fails
command.CommandText="insert into [HP
Calculator APR$] (F1,F2) values ('aadbb','ddeef')";
int i=command.ExecuteNonQuery();

//update fails as well, the exception is:No
value given for one or more required parameters.

StringBuilder sb = new StringBuilder("update [HP
Calculator APR$] set ");
sb.AppendFormat("{0}='{1}'", "G3",
quoteRequest.TotalPrice);

sb.Append(" where E1='0'");
command.CommandText = sb.ToString();
command.ExecuteNonQuery();

}

I am totally confused, can someone help me?

Thanks
 
M

Mary Chipman [MSFT]

I'd try on one of the Access newsgroups -- I don't think that many
people are familiar with Ace around here.

--Mary
 
P

Paul Clement

¤ Hi,
¤
¤ I already searched old posts, but still confused.
¤ I am a asp.net application and user "everyone" does have write and
¤ read right to the excel file

You may need to provide full access to the folder where the file is located. I would give that a try
first.


Paul
~~~~
Microsoft MVP (Visual Basic)
 

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

Top