Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I use ado.net to write certain cell in an excel sheet and then read some value back. The read value is calculated based on the written cell. I can write to the sheet without any exception thrown, but when I try to read it back, the value I read is the old one, not the value it should be (the value should be calculated based on the written value I provided). Strange thing is that if I put a break point between read and write, when my code breaks, I just open the sheet using excel (I can see the values have been updated) and click save in excel. Then the value I read will contain correct written values. So I guess it is some dirty read or dirty write thing. Can someone help me? Many Thanks My code to write and read excel : DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.OleDb" ); FinanceQuoteResponse response=null; using (DbConnection conn = factory.CreateConnection()) { conn.ConnectionString = this.ConnString; using (DbCommand command = conn.CreateCommand()) { //first update value StringBuilder sb = new StringBuilder("update [LP Calculator APR$] set "); sb.AppendFormat("{0}={1},", "G3", request.TotalPrice); sb.AppendFormat("{0}={1},", "E4", request.Deposit); sb.AppendFormat("{0}={1},", "G6", request.FinanceQuoteDetail.DocumentationFee); sb.AppendFormat("{0}={1},", "G7", request.FinanceQuoteDetail.Apr); sb.AppendFormat("{0}={1},", "G11", request.FinanceQuoteDetail.OptionToPurchaseFee); sb.AppendFormat("{0}={1}", "G12", request.FinanceQuoteDetail.CreditFacilityFee); command.CommandText = sb.ToString(); conn.Open(); command.ExecuteNonQuery(); //now calculate command.CommandText = "SELECT * FROM [LP Calculator APR$E5:E27]"; DbDataAdapter adapter = factory.CreateDataAdapter(); adapter.SelectCommand = command; DataSet output = new DataSet(); adapter.Fill(output); foreach (DataRow row in output.Tables[0].Rows) { //FinanceQuoteResponse response=new FinanceQuoteResponse } } Jerry |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
UDF that participates in circularity always dirty | Excel Programming | |||
Determine if template file is dirty | Excel Programming | |||
Removing Dirty Data From an Imported DOS database | Excel Programming | |||
using Dirty Method | Excel Programming | |||
How to tell if a range or cell is dirty | Excel Programming |