a b

a b

  • NA
  • 1
  • 3.6k

C# Problems during saving data on a Excel File shared in LAN

Jan 13 2012 2:00 PM
Hello All,
I'm a newbie on C# and i have worked exclusively on Access Databases and ADO.NET - OLEDB. This time I have a simple Excel 2010 Sheet made by 5 columns. I have to iterate thru the first 3, checking inside and then write data on 4th and 5th.
This file Excel is a "compatibility mode" and shared in a little office network and used by about 20 people max.
I have this problem:
If I write data into the 4 and 5th cells on my local Pc or where I have the IDE (Visual Studio 2008) all is working normally, I can write data without any problem; but, installing the program on my Desktop at work and working on LAN, happens the following:
I write data, I save data, I close the program, then I open the sheet and I see my data written; but after a while (just a few minutes), they are disappeared.
The debug in VS2008 doesn't report errors.
So I'm thinking the problem could be given by the following string, but I don't know if there is a real error in it.
----------------------------------------------------------------------------------------------------
public static string connSQL_ExtFileChecked()
{
string connessioneSQL;
string extFile=Path.GetExtension(VarP.fileAnalizzato);

if (extFile == ".xls")
{
connessioneSQL = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + VarP.fileAnalizzato
+ ";" + "Mode=ReadWrite;" + "Extended Properties=Excel 8.0;";
}
else
{
connessioneSQL = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + VarP.fileAnalizzato
+ ";" + "Mode=ReadWrite;" + "Extended Properties=Excel 12.0;";
}
return connessioneSQL;
}

Could anyone help me, please ?
Regards,
Pim.


Answers (1)