我一直在运行代码/调试器,甚至设置断点,这样我就可以单步执行代码并且无法找到我知道的语法错误在哪里,在这个 C# 方法中用于在 c-tree 中创建新表数据库。
这是代码:
/*
Define() method
where specific data definitions are established also will include the definition of the table
being created as well as defining rows and columns of the table
*/
public static void Define()
{
Console.WriteLine("DEFINE");
try
{
//Creation of the table with the specified data types and the column Names
Console.WriteLine("\tCreating table...");
cmd.CommandText = "CREATE TABLE testData (" +
"Trackingid VARCHAR(35)," +
"dates DATETIME," +
"Name_Of_Recipient VARCHAR(35)," +
"addresss VARCHAR(35)," +
"address2 VARCHAR(31)," +
"City VARCHAR(34)," +
"Town VARCHAR(23)," +
"states VARCHAR(5)," +
"ZipCode INT )";
cmd.ExecuteNonQuery();
}
catch(CtreeSqlException e)
{
Console.WriteLine(e + " could not define this table");
}
catch(Exception e)
{
Console.WriteLine(e + "Error the table could not be defined");
}
}
就像我之前提到的那样,我多次尝试单步执行代码,我假设我可能有很多列条目?还是严重依赖 VARCHAR 数据类型?
抛出异常消息:
" Creating table...
Ctree.Data.SqlClient.CtreeSqlException (0x7FFFB1DD): Syntax error ---> Ctree.SqlClient.Common.FcSqlException: Syntax error
at Ctree.SqlClient.FcSqlXApi.SQLExec(FcStatement stmt, Int32 InStatementType, FcSqlDA ida, FcSqlDA oda, FcSqlCA sqlca)
at Ctree.SqlClient.FcSqlXApi.Prepare(FcStatement stmt, FcSqlDA input_sqlda, FcSqlDA output_sqlda, Int32 fetchSize)
at Ctree.SqlClient.FcConnection.Prepare(FcStatement statement, FcSqlDA inputDA, FcSqlDA outputDA, Int32 fetchSize)
at Ctree.SqlClient.FcPreparedStatement..ctor(FcConnection connexion, String sql, Int32 fetchSize, Int32 timeout)
at Ctree.Data.SqlClient.CtreeSqlCommand.InternalPrepare(Boolean resultSet)
at Ctree.Data.SqlClient.CtreeSqlCommand.ExecuteNonQuery()
at Ctree.Data.SqlClient.CtreeSqlCommand.ExecuteNonQuery()
at DBbeta.Program.Define() in C:\Users\WVX0DYQ\source\repos\DBbeta\DBbeta\Program.cs:line 76 could not define this table"