| 发表于:2007-03-25 12:07:14 楼主 |
用的是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字段类型不行. |
|
|
|
|