从.NET向Access(Jet)表添加列 [英] Add columns to an Access (Jet) table from .NET
本文介绍了从.NET向Access(Jet)表添加列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们的应用程序(已部署)正在使用Access/Jet数据库.我们软件的即将发布的版本在其中一个表中需要一些其他列.我需要先检查这些列是否存在,然后再添加(如果不存在).
Our app (already deployed) is using an Access/Jet database. The upcoming version of our software requires some additional columns in one of the tables. I need to first check if these columns exist, and then add them if they don't.
有人可以按正确的方向提供快速的代码示例,链接或微调吗?
Can someone provide a quick code sample, link, or nudge in the right direction?
(我正在使用c#,但也可以使用VB.NET示例).
(I'm using c#, but a VB.NET sample would be fine, too).
推荐答案
离我远去,但类似:
Dim conn as New AdoConnection(someConnStr)
Dim cmd as New AdoCommand
cmd.Connection = conn
cmd.CommandText = "ALTER TABLE X ADD COLUMN y COLUMNTYPE"
cmd.ComandType = CommandType.Text
cmd.ExecuteNonQuery()
这篇关于从.NET向Access(Jet)表添加列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文