2
2ndreconmarine
Guest
I have a VS 2010 Professional application. I need to read and write data to an excel file. I read the data, then process it, then write back. I can open the Excel file just fine and can read the data. However, I cannot write to the file; it always opens as "readonly". I have tried several solutions offered on these forums. The connection string has "ReadOnly=False". I make sure that there are no other processes running that access the file. I have set all of the file and directory permissions so that everyone has full access. The Data source is defined in the ODBC manager and the "read only" box is cleared.
The data access string (generated by the VS 2010 Studio Compiler) is:
return _T("DSN=Testdataup;DBQ=D:\\myprojects\\testdata.xls;DefaultDir=D:\\myprojects;ReadOnly=False;DriverID=1046;FIL=excel 12.0;MaxBufferSize=2048;PageTimeout=5");
I have also tried subsets of this, as the DSN field is the only one necessary to open the file.
When the program runs, I get the following warning messages:
Warning: ODBC Success With Info, Drivers SQLSetConnectAttr failed
State:IM006,Native:0,Origin:[Microsoft][ODBC Driver Manager]
Warning: data source is readonly.
My test program is the following. Note that I test to make sure that the file is both Updateable and Appendable.
bool test = m_datatestSet.CanAppend(); // Test if can append
bool test1 = m_datatestSet.CanUpdate();
m_datatestSet.AddNew(); // Prepare a new row
m_datatestSet.m_a = m_outcola; // Insert values
m_datatestSet.m_b = m_outcolb;
m_datatestSet.m_c = m_outcolc;
m_datatestSet.m_d = m_outcold;
m_datatestSet.Update(); // Update the file
I set a breakpoint in the debugger after the tests to make sure I can write, but every time the CanUpdate() function returns false. (CanAppend() returns true, but you need to Update after the AddNew() function.
Thank you for any help.
Continue reading...
The data access string (generated by the VS 2010 Studio Compiler) is:
return _T("DSN=Testdataup;DBQ=D:\\myprojects\\testdata.xls;DefaultDir=D:\\myprojects;ReadOnly=False;DriverID=1046;FIL=excel 12.0;MaxBufferSize=2048;PageTimeout=5");
I have also tried subsets of this, as the DSN field is the only one necessary to open the file.
When the program runs, I get the following warning messages:
Warning: ODBC Success With Info, Drivers SQLSetConnectAttr failed
State:IM006,Native:0,Origin:[Microsoft][ODBC Driver Manager]
Warning: data source is readonly.
My test program is the following. Note that I test to make sure that the file is both Updateable and Appendable.
bool test = m_datatestSet.CanAppend(); // Test if can append
bool test1 = m_datatestSet.CanUpdate();
m_datatestSet.AddNew(); // Prepare a new row
m_datatestSet.m_a = m_outcola; // Insert values
m_datatestSet.m_b = m_outcolb;
m_datatestSet.m_c = m_outcolc;
m_datatestSet.m_d = m_outcold;
m_datatestSet.Update(); // Update the file
I set a breakpoint in the debugger after the tests to make sure I can write, but every time the CanUpdate() function returns false. (CanAppend() returns true, but you need to Update after the AddNew() function.
Thank you for any help.
Continue reading...