Bitrix24
Bitrix24

Reputation: 211

how to create a table named "realizations" with another file name? (FoxPro)

I have to create a table with name "Realizations" but it's file must be named like today's date (example "12092016.dbf"). I can get current date from my C# program but how to set the file name in query string???

My data engine is Visual FoxPro.

Upvotes: 1

Views: 137

Answers (1)

Cetin Basoz
Cetin Basoz

Reputation: 23797

Is this what you mean? (I assume you mean C# code):

using (var connection = new OleDbConnection(@"Provider=VFPOLEDB;Data Source=c:\My Data Folder"))
{
    var cmd = new OleDbCommand(@"select * from Realizations 
      into table (?)",connection);
    cmd.Parameters.AddWithValue("tableName", DateTime.Today.ToString("ddMMyyyy"));
    connection.Open();
    cmd.ExecuteNonQuery();
    connection.Close();
}

Please note that, naming a table like this is not very safe and also a date string in the format ddMMyyyy is not very safe. Maybe you would want to name it like Realizations_20160913. If so then you could say:

cmd.Parameters.AddWithValue("tableName", "Realizations_" +
    DateTime.Today.ToString("yyyyMMdd"));

Upvotes: 1

Related Questions