在MDB数据库中设置小数位 [英] Setting decimal places in an MDB database

查看:150
本文介绍了在MDB数据库中设置小数位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究的项目的一部分是以编程方式创建一系列MDB文件,这些文件将是最终的交付成果.客户端的规格要求表中的某些字段具有3个小数位.

Part of a project I am working on is programmatically create a series of MDB files which will be the final deliverables. The specs from the client ask for some fields in the tables to have 3 decimal places.

我首先使用python创建mdb文件,然后为了能够将列更改为DECIMAL(10,3),我使用ADODB(C#,.NET 4.0)-因为我找不到合适的东西Python.问题是,这对于客户来说还不够.他们想打开MDB并在设计模式"下​​查看将这些字段设置为3的小数位.如果不这样,则文件不被接受.

I create the mdb files using python at first, and then to be able to alter the columns to DECIMAL (10,3), I use ADODB (C#, .NET 4.0) - as i couldn't find something suitable in Python. Problem though is that this will not be enough for the client. They want to open the MDB and in Design Mode to see the Decimal places for these fields to be set to 3. If they are not, the file is not accepted.

现在,我花了3天的大部分时间来提出解决方案.一个可能的候选对象是DAO和Field2对象,但是到目前为止,这个对象还不知我.我正在使用Microsoft DAO 3.6对象,但Field2似乎不是程序集的一部分.而且甚至不知道这是否真的会做所需的事情……

It has now taken me the best part of 3 days trying to come up with a solution. One likely candidate was DAO and the Field2 object but this object has so far eluded me. I am using the Microsoft DAO 3.6 Objects but Field2 doesn't seem to be part of the assembly. And dont even know if this will actually do what is required...

有人知道这样做的方法吗?不用担心它的DAO,ADO,OLEDB或其他3个字母的缩写是不是很诚实?我怎么能这样:

Does anyone know a way to do this? Don't care if its DAO, ADO, OLEDB or any other 3 letter acronym to be honest? How can I get from this:

对此-编程上??

推荐答案

我可以告诉您如何在VBA/DAO中执行此操作,这可能会给您一些想法.您必须先附加属性:

I can tell you how to do this in VBA/DAO, which may give you some ideas. You must append the property first:

sSQL = "create table testX (id counter, anumber decimal(10,3))"
CurrentProject.Connection.Execute sSQL

Dim db As Database
Dim tdf As TableDef
Dim fld As dao.Field

Set db = CurrentDb

Set tdf = db.TableDefs("testX")
Set fld = tdf.Fields("anumber")
'fld.Properties("DecimalPlaces") = 3
Set prp = fld.CreateProperty("DecimalPlaces", dbByte, 3)
tdf.Fields("anumber").Properties.Append prp

这篇关于在MDB数据库中设置小数位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆