Question

I have got this OleDbCommand which should INSERT INTO netpokl.DBF but it gives this exception - Not a valid file name

 odcCON.Open();
                     OleDbCommand odc = new OleDbCommand("INSERT INTO netpokl (Castka,Akce) values(@castka,@akce)", odcCON);
                     odc.Parameters.AddWithValue("@castka",textBox2.Text);
                     odc.Parameters.AddWithValue("@akce",vyberradek);

                     odc.ExecuteNonQuery();
                     odcCON.Close();

this is the OleDbConnection

 public static string zapisDBF = "\\\\SERVER\\Transfer\tata\netpokl.DBF";
 OleDbConnection odcCON = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='"+zapisDBF+"'");

Solution was:

  public static string zapisDBF = @"\\SERVER\Transfer\tata\netpokl.DBF";

Another problém occured : Unrecognized database format \SERVER\Transfer\tata\netpokl.DBF

Was it helpful?

Solution

there is a problem with your string,

public static string zapisDBF = "\\\\SERVER\\Transfer\\tata\\netpokl.DBF";
                                          //          ^     ^ missing

or simply use verbatim string

public static string zapisDBF = @"\\SERVER\Transfer\tata\netpokl.DBF";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top