数据库中的SQL逻辑检查 - VB.net [英] SQL logical check in database - VB.net

查看:88
本文介绍了数据库中的SQL逻辑检查 - VB.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Guys,



我试图访问MSI数据库,我可以在数据库中插入,删除等。

我的问题是如何检查数据库中的现有条目和如果不存在则插入。



我的代码中出现错误。



installer = CreateObject(WindowsInstaller.Installer)

database = installer.OpenDatabase(Path,1)'数据库将被打开进行编辑。



SQLquery =IF NOT EXISTS(SELECT * FROM database WHERE`Feature` ='Complete')INSERT INTO Feature(`Feature`,`Feature_Parent`,`Title `,`Description`,`Display`,`Level`,`Directory_`,`Attributes`)VALUES('Complete','','Complete','','2','1','INSTALLDIR', '0')



View = database.OpenView(SQLquery)---------> 错误:COMException未处理, OpenView,Sql







请协助我解决了代码中的错误。

Hello Guys,

Am trying to access the MSI database, I can insert, delete etc. in the database.
My issue is how to check for existing entry in the database and Insert if not exists.

I get error in my code below.

installer = CreateObject("WindowsInstaller.Installer")
database = installer.OpenDatabase(Path, 1) 'database will be opened for editing.

SQLquery = "IF NOT EXISTS(SELECT * FROM database WHERE `Feature` = 'Complete') INSERT INTO Feature (`Feature`, `Feature_Parent`, `Title`, `Description`, `Display`, `Level`, `Directory_`, `Attributes`) VALUES ('Complete', '', 'Complete', '', '2', '1', 'INSTALLDIR', '0' )"

View = database.OpenView(SQLquery) ---------> Error: COMException was Unhandled, OpenView,Sql



Please assist me in solving the error in the code.

推荐答案

查看文档 [ ^ ],Windows Installer不支持 IF NOT EXISTS(...)子句。您需要发出单独的 SELECT INSERT 命令。
Looking at the documentation[^], Windows Installer does not support the IF NOT EXISTS(...) clause. You'll need to issue separate SELECT and INSERT commands.


这篇关于数据库中的SQL逻辑检查 - VB.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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