开发者

How do I create an OLEDB table with the column named "DATE"?

We're using the Microsoft Jet OLEDB provider to insert data into a legacy system.

This system requires that we insert data by creating a DBF file, which has the format of:

employee Numeric (10,0),
jobcode Numeric (10,0),
date date

So, we are doing the following:

string strConnDbase = @"Provider = Microsoft.Jet.OLEDB.4.0" +
    ";Data Source = " + ruta +
    ";Extended Properties = dBASE IV" +
    ";User ID=Admin;Password=;";

Then, we run a command like:

string sql = "CREATE 开发者_如何学JAVATABLE 20110112 ( EMPLOYEE Numeric(10,0), JOBCODE Numeric(10,0), DATE Date)";

Unfortunately, this "sql" statement is not running. IE, the column named "date" is a keyword, so we cannot create the table.

We've tried escaping (single and double quotes) the column name, but that doesn't work either.

How can we build a table with the column being named "date"?

Thanks!

-- Anthony


Try square brackets:

CREATE TABLE 20110112 ( EMPLOYEE Numeric(10,0), JOBCODE Numeric(10,0), DATE [Date])

I don't have an OLEDB target handy, so this is just a guess, FWIW.


You can't create a table starting with a number... and it's really bad practice to create column names based on reserved words (date).

Just prefix with SOMEthing... even if its just "T" for "Table".

create table T20110112

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜