We've been programming with a connection that "simulates" a CSV into a database.
We used it with all our applications, but now we needed to do the programming on Visual C# Express 2008 while we previously used Visual Studio 2012.
We changed our Framework from 4.5 to 3.5 because that is what Express 2008 can use.
Then we removed some "unneeded" using Systems. Now we removed the try and catch to see what the problem was which is: "Provider cannot be found. It may not be properly installed."
This is the code what was wrong:
string fileNeem = Path.GetFileName(strFileName4);
string sepperator3 = Convert.ToString(textBox2.Text);
string root = Path.GetDirectoryName(strFileName4);
if (File.Exists(@"" + root + "/schema.ini")) { File.Delete(@"" + root + "/schema.ini"); }
string[] lines = { "[" + fileNeem + "]", "Format=Delimited(" + sepperator3 + ")", "DecimalSymbol=(,)" };
System.IO.File.WriteAllLines(@"" + root + "/schema.ini", lines);
ADODB.Connection oConn = new ADODB.Connection();
oConn.Open("Provider=Microsoft.Jet.OleDb.4.0; Data Source = " + System.IO.Path.GetDirectoryName(strFileName4) + "; Extended Properties = \"Text;HDR=YES;FMT=Delimited\";", "", "", 0);
string strQuery = "SELECT * FROM [" + System.IO.Path.GetFileName(strFileName4) + "]";
ADODB.Recordset rs3 = new ADODB.Recordset();
System.Data.OleDb.OleDbDataAdapter adapter = new System.Data.OleDb.OleDbDataAdapter();
rs3.Open(strQuery, "Provider=Microsoft.Jet.OleDb.4.0; Data Source = " + System.IO.Path.GetDirectoryName(strFileName4) + "; Extended Properties = \"Text;HDR=YES;FMT=Delimited\";",
ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, 0);
adapter.Fill(dtAttrSet, rs3);
dtAttrSet.Columns.Add("");
if (File.Exists(@"" + root + "/schema.ini")) { File.Delete(@"" + root + "/schema.ini"); }
rs3.Close();
oConn.Close();
gvAttributeSet.DataSource = dtAttrSet;
return dtAttrSet;
Also, we use a schema.ini file to store the delimiter. This file is removed soon after the datatable is filled.
I have seen a lot of questions and answers but it seems that it is ASP or they used Excel.
Is there anything we did wrong?