日期:2014-05-19  浏览次数:20819 次

oledb create dbase Iv 表的奇怪问题. 请教各位.
用的是oledb连接.   创建表成功了,但是字段长度不对.
如下:
private   System.Data.OleDb.OleDbConnection   getDBaseConnection(string   directoryPath)
                {
                        if   (!System.IO.Directory.Exists(directoryPath))
                        {
                                throw   new   Exception( "指定的路径不存在 ",   new   Exception());
                        }
                        string   connectionString   =   "Provider=Microsoft.Jet.OLEDB.4.0;Data   Source= "   +   directoryPath   +   "   ;Extended   Properties=dBASE   IV;User   Id=;Password=; ";

                        System.Data.OleDb.OleDbConnection   conn   =   new   System.Data.OleDb.OleDbConnection(connectionString);

                        return   conn;

                }

private   void   createTable()
{
                      string   fileName=@ "D:\dataBase\waterCard.dbf ";
                      OleDbConnection   conn   =   GetDBaseConnection(new   FileInfo(fileName).DirectoryName);
                      createTableSql   =   @ "create   table   D:\dataBase\watercard.dbf   (custId   NUMERIC(11)   ,custNo   NUMERIC(7,0)   ,ajustQut   NUMERIC(9,2)) ";
                        OleDbCommand   oleCmd   =   new   OleDbCommand(createTableSql,   conn);

                        try
                        {
                                conn.Open();
                                oleCmd.ExecuteNonQuery();
                        }
                        catch   (Exception   ex)
                        {
                                throw   new   Exception(ex.Message,   ex);
                        }
}


程序运行正常,但是表创建后字段长度并非create   table   语句中制定的长度
,而是都变成了   (20,5);
我调试了好长时间了,其他数据类型如DATE,LOGICAL,Character都没问题,就是NUMERIC字段类型不行.


------解决方案--------------------
没遇到过...

学习,关注一下...