1
votes

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.

1
Your question is not clear. You are saying you want to create a table with name "Realizations" and then you are saying it must be named like today's date. How would a file's name be both "realizations" and also today's date as a string at the same time? Second, what it has to do with a query? What is that you are really trying to do and cannot? - Cetin Basoz
@CetinBasoz thx for comment. I need differed name of table and file of this table. Now it's clear? - Bitrix24

1 Answers

1
votes

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"));