English 中文(简体)
• 如何获得与MySQL有联系的汽车加油场的价值?
原标题:How to obtain value of auto_increment field in Access linked to MySQL?
最佳回答

Solved (and blobed) as below

我正在对一套访问数据库进行升级,以取代由ODBC连接的MySQL查询档案数据库。 除了将记录插入一个带有自动加油栏的表格和重新计算刚刚制造的补贴的价值这一共同概念外,一切似乎都顺利。 当然,关于购买力平价或类似标准,只能使用。

SlectT LAST_INSERT_ID()

检索身份证的功能。 然而,MySQL文件本身指出,这不利于某些ODBC应用,如Delphi或准入,并建议使用

西欧和其他国家:

不幸的是,我在“无障碍申请”中呼吁我这样做,似乎在网络上发表了若干评论,认为这确实是不可靠的,因为访问可能减少数据联系,并重新连接现场,从而使得呼吁失效。

作为备选案文,我决定利用MySQL的功能在表格上添加一个空白记录,归还使用该记录来更新记录(这符合现有应用的代码式)。 不幸的是,这种显然简单的工作方式,不能简单地简单地简单地简单,因为MySQL的长篇大论使得找到既能够带来又能够带来挑战的变量的有效法典。 网上的几个例子将在有限的领域开展工作,既使用国内的变量,也使用成果的变量,但未能与两者合作。

我的最后解决办法是在我所部署的MySQL.1和“2003年准入”组合上工作的。

MySQL程序

DELIMITER $$

CREATE
    PROCEDURE `alicedata`.`sp_ins_identity`(IN tablename VARCHAR(50))
    BEGIN
    SET @result = 0;
    SET @sqlproc = CONCAT("INSERT INTO ",tablename," () VALUES ();");
    PREPARE s1 FROM @sqlproc;
    EXECUTE s1;
    DEALLOCATE PREPARE s1;
    SlectT LAST_INSERT_ID();
    END$$

这一程序非常有用,因为它将插入一行,并在任何表格中填入所有未清的田地或非核区的id。 我称职:

Public Function InsertMySQLIdentityRow(DSN As String, Tablename As String) As Integer
On Error GoTo Err_InsertMySQLIdentity

Dim cnnSQL As New ADODB.Connection
Dim cmdSQL As ADODB.Command
Dim pid As Integer
Dim rs
Dim strSQL As String

      initialize
    pid = 0

      set up ADO connection
    Set cnnSQL = New ADODB.Connection
    cnnSQL.Open DSN

      execute the procedure - note that assembling by parameter fails to handle IN or OUT correctly

    Set cmdSQL = New ADODB.Command
    cmdSQL.ActiveConnection = cnnSQL

    strSQL = "call sp_ins_identity( " & Tablename & " );"
    Set rs = CreateObject("ADODB.Recordset")
    Set rs = cnnSQL.Execute(strSQL)

    If Not rs.EOF Then
      pid = rs(0)
    End If

      clean up
    Set rs = Nothing
    Set cmdSQL = Nothing
    cnnSQL.Close
    Set cnnSQL = Nothing

Exit_InsertMySQLIdentity:
    InsertMySQLIdentityRow = pid
    Exit Function

Err_InsertMySQLIdentity:
    MsgBox Err.Number & Err.Description
    Resume Exit_InsertMySQLIdentity
End Function

这部法典有些不寻常之处,因为通常,在MSSQL方面,你将使用一种不平衡的程序电话,但由于MySQL ODBC(或至少与无障碍环境不兼容)的丑闻,上述数据似乎是唯一能够通过和返还数据的方法。

问题回答

暂无回答




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签