Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / February 2008

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DAXU - 11 Feb 2008 17:35 GMT
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
Mary Chipman [MSFT] - 12 Feb 2008 14:58 GMT
I'd try on one of the Access newsgroups -- I don't think that many
people are familiar with Ace around here.

--Mary

>Hi,
>
[quoted text clipped - 49 lines]
>
>Thanks
Paul Clement - 12 Feb 2008 21:31 GMT
¤ 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)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.