如何通过 OleDb 确定 MS Access 字段大小
现有应用程序是用 C# 编写的。 在启动期间,应用程序调用虚拟方法来对数据库进行更改(例如,新版本可能需要计算新字段或其他内容)。 将打开的 OleDb 连接传递到该方法中。
我需要更改字段宽度。 ALTER TABLE 语句工作正常。 但如果字段已经是适当的大小,我想避免执行 ALTER TABLE 语句。 有没有办法使用相同的 OleDb 连接来确定 MS Access 字段的大小?
The existing application is in C#. During startup the application calls a virtual method to make changes to the database (for example a new revision may need to calculate a new field or something). An open OleDb connection is passed into the method.
I need to change a field width. The ALTER TABLE statement is working fine. But I would like to avoid executing the ALTER TABLE statement if the field is already the appropriate size. Is there a way to determine the size of an MS Access field using the same OleDb connection?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是我根据 shhkalpesh 的回答得出的结论:
Here's what I came up with based on shahkalpesh's answer:
不确定我是否完全理解你的问题。
但是您可以查询表中的 0 行 (SELECT 1 FROM myTable WHERE 1= 0)
并且您可以使用记录的字段集合,通过名称或索引引用该字段
并使用字段的属性,如大小、类型等。
这有帮助吗?
Not sure if I understand your question completely.
But you could query the table for 0 rows (SELECT 1 FROM myTable WHERE 1= 0)
And you could use recordet's field collection, refer to that field by name or index
and use field's property like size, type etc.
Does that help?