1. <legend id='mAM5p'><style id='mAM5p'><dir id='mAM5p'><q id='mAM5p'></q></dir></style></legend>

      <i id='mAM5p'><tr id='mAM5p'><dt id='mAM5p'><q id='mAM5p'><span id='mAM5p'><b id='mAM5p'><form id='mAM5p'><ins id='mAM5p'></ins><ul id='mAM5p'></ul><sub id='mAM5p'></sub></form><legend id='mAM5p'></legend><bdo id='mAM5p'><pre id='mAM5p'><center id='mAM5p'></center></pre></bdo></b><th id='mAM5p'></th></span></q></dt></tr></i><div id='mAM5p'><tfoot id='mAM5p'></tfoot><dl id='mAM5p'><fieldset id='mAM5p'></fieldset></dl></div>
    1. <small id='mAM5p'></small><noframes id='mAM5p'>

      <tfoot id='mAM5p'></tfoot>
      • <bdo id='mAM5p'></bdo><ul id='mAM5p'></ul>

    2. 如何使用 VB6 在 SQLite 中返回 AUTO INCREMENT 列的值

      时间:2023-07-18

          <small id='QixIw'></small><noframes id='QixIw'>

          <legend id='QixIw'><style id='QixIw'><dir id='QixIw'><q id='QixIw'></q></dir></style></legend>
        1. <tfoot id='QixIw'></tfoot>
        2. <i id='QixIw'><tr id='QixIw'><dt id='QixIw'><q id='QixIw'><span id='QixIw'><b id='QixIw'><form id='QixIw'><ins id='QixIw'></ins><ul id='QixIw'></ul><sub id='QixIw'></sub></form><legend id='QixIw'></legend><bdo id='QixIw'><pre id='QixIw'><center id='QixIw'></center></pre></bdo></b><th id='QixIw'></th></span></q></dt></tr></i><div id='QixIw'><tfoot id='QixIw'></tfoot><dl id='QixIw'><fieldset id='QixIw'></fieldset></dl></div>
            • <bdo id='QixIw'></bdo><ul id='QixIw'></ul>
                <tbody id='QixIw'></tbody>
                本文介绍了如何使用 VB6 在 SQLite 中返回 AUTO INCREMENT 列的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我在 SQLite 中有一个表:

                创建表事件类型"([EventTypeID] 整数主键,[EventTypeName] VARCHAR(50) NOT NULL UNIQUE);

                由于 EventTypeID 是一个整数和一个主键,这会自动使它成为一个自动递增的列,并且工作正常.

                我想在表中插入一行并从 VB6 中获取新增加的值.

                Dim oRs as Recordset将 oCmd 调为新命令oCmd.ActiveConnection = GetConnection()oCmd.Source = "插入 EventType (EventTypeName) 值 ('blah')"oCmd.执行

                是否有一种自动检索新创建的 EventTypeID 而无需发出另一个查询的方法(从 EventType 中选择 max(EventTypeID))?

                我似乎记得很久以前的 VB6 天,有一种方法可以做到这一点.

                解决方案

                SQLite 是否支持 SCOPE_IDENTITY?

                一个>

                <块引用>

                查看常见问题解答.这sqlite3_last_insert_rowid()函数会做到的.小心的虽然触发

                未经测试,但您应该能够在一次调用中发送两个语句.自从我写任何 VB6 以来已经有一段时间了.这也不是 SQL 注入安全.

                Dim oRs as Recordset将 sSql 调暗为字符串sSql = "INSERT INTO EventType (EventTypeName) VALUES ('blah'); SELECT last_insert_rowid() FROM EventType"oRs.Open sSql oConn

                I have a table in SQLite:

                CREATE TABLE "EventType" 
                (
                [EventTypeID] INTEGER PRIMARY KEY, 
                [EventTypeName] VARCHAR(50) NOT NULL UNIQUE
                );
                

                Since EventTypeID is an integer and a primary key, that automatically makes it an auto-incrementing column, and that works fine.

                I'd like to insert a row into the table and get the newly incremented value from VB6.

                Dim oRs as Recordset
                dim oCmd as new Command
                
                oCmd.ActiveConnection = GetConnection()
                oCmd.Source = "insert into EventType (EventTypeName) values ('blah')"
                oCmd.Execute
                

                Is there an automatic way to retrieve the newly created EventTypeID without having to issue another query (select max(EventTypeID) from EventType))?

                I seem to remember from VB6 days long time ago, that there was a way to do that.

                解决方案

                Does SQLite support SCOPE_IDENTITY?

                Check out the FAQ. The sqlite3_last_insert_rowid() function will do it. Careful of triggers though

                Not tested, but you should be able to send both statements in one call. It's been a while since I wrote any VB6. Also this is not SQL injection safe.

                Dim oRs as Recordset
                dim sSql as String
                sSql = "INSERT INTO EventType (EventTypeName) VALUES ('blah'); SELECT last_insert_rowid() FROM EventType"
                oRs.Open sSql oConn
                

                这篇关于如何使用 VB6 在 SQLite 中返回 AUTO INCREMENT 列的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何在不指定列名的情况下使用 AUTO_INCREMENT 列将新行插入到数据库中? 下一篇:更改步骤 auto_increment 字段增量

                相关文章

                <tfoot id='UsLej'></tfoot>
                <i id='UsLej'><tr id='UsLej'><dt id='UsLej'><q id='UsLej'><span id='UsLej'><b id='UsLej'><form id='UsLej'><ins id='UsLej'></ins><ul id='UsLej'></ul><sub id='UsLej'></sub></form><legend id='UsLej'></legend><bdo id='UsLej'><pre id='UsLej'><center id='UsLej'></center></pre></bdo></b><th id='UsLej'></th></span></q></dt></tr></i><div id='UsLej'><tfoot id='UsLej'></tfoot><dl id='UsLej'><fieldset id='UsLej'></fieldset></dl></div>

                    <bdo id='UsLej'></bdo><ul id='UsLej'></ul>
                  1. <legend id='UsLej'><style id='UsLej'><dir id='UsLej'><q id='UsLej'></q></dir></style></legend>

                  2. <small id='UsLej'></small><noframes id='UsLej'>