ActiveX ADODB LAST_INSERT_ID() returns zero

Hey everybody,

I connect to a MySQL database using Microsoft ActiveX ADODB (ADOBD.recordset) classes. This works very well for select, INSERT and UPDATE MySQL base, and I'm sure that others that I have not yet tried. The table has a unique identifier column named 'id' auto-increment, and I would like to return the last value inserted into the table. However, the execution of SELECT LAST_INSERT_ID() returns 0.

I looked into it, and some people mentioned that the TEEN can not handle BIGINT, so I added "Option = 16384" my connection string (FLAG_NO_BIGINT) and still no luck. Others have mentioned that the AUTO_IS_NULL database option is at the origin of the questions, so I tried that too and it does not always work.

I also tried the command 'SELECT LAST_INSERT_ID() FROM table', and which returns an array of 0s, with a length equal to the length of the table. It is closer, but because the items can be removed from the table, I can't use it for my purposes.

Does anyone have information on this?

On a related, but much less important topic, ADODB.recordset can execute multiple queries or commands in a single call? For example, sending multiple INSERT commands.

Have you tried something like:

Select max (my_id_field)
From my_table;

In turn mySQL supports the new standard SQL 'back' clause in inserts?

On your related question, you don't need a recordset to send a command. Use the execute method connection when you're not going to be return data. What about queries, the answer is Yes, but with caveats.

Mike...

Tags: NI Software

Similar Questions

  • Table of index always returns zero when reading the table 3D

    I have a 9 x 2000 x 5 table table 3D diamension.  I have this table filled with data and when I try to read a data point unique on the table the function Index Array always reads zero. I place a probe on the 3D input array and when I put in the index of the probe to the same data point the probe shows the value stored in the table. I also have an indicator showing the 3D table and it displays data in all locations. For example if I try to read the location 0, 144.0 in 3D it array always return zero. Yet I know that the value of this element is 6.8616E - 5. Each item I try to retreave table gives zero.

    Anyone saw the Index room table this kind of behavior?

    Problem solved. As usual, it was pilot error on my part had knocked down the lines of lines and columns.

  • MS Access AS condition returns zero records

    When you use the 'WHERE' clause to the status of 'LIKE' with database connectivity kit, I have zero records returned by my Access database. The exact same query text running in MS Access returns the correct number of records.

    "I use the" Open DB: ', DB run the query "and then"extract the data recordset"live

    Replacement of SIMILAR with a simple "=" will return the corresponding as expected a record.

    Is there a known issue with the condition of 'LIKE '?

    Bill

    LabVIEW 2011 SP1

    While the former, this can enlighten us:

    http://forums.devarticles.com/Microsoft-Access-development-49/like-operator-not-working-with-Ms-ACCE...

    Your SIMILAR statement may not be properly trained.  Insida access, the connection is different from the one through ODBC, and similar generic characters are different as well.

  • CTRL val get reference returns zero refnum

    I use 'ctrl val get' in a vi.  The value it gets is a bunch of references, the references are returned with a value of zero.  Is there a prohibition against the use of 'ctrl val get' by references?

    Adde a probe earlier to see what Ref was not valid.

    Ben

  • GetRawInputDeviceList / GetRawInputDeviceInfo return zero for hid.usUsage and hid.usUsagePage _

    GetRawInputDeviceList call (.) / GetRawInputDeviceInfo works great on Windows Vista and Windows 7, but running the same code on a PC running Windows XP, returns RID_DEVICE_INFO structures where the fiedls. hid.usUsage and. hid.usUsagePage are filled with zeros.

    This is not implemented on Windows XP?

    UINT nDevices;
    UINT uiCount = GetRawInputDeviceList (NULL, & nDevices,

    sizeof (RAWINPUTDEVICELIST));
    If (-1! = uiCount & nDevices > 0)
    {
    RAWINPUTDEVICELIST * pRawInputDeviceList = new RAWINPUTDEVICELIST [nDevices];
    If (pRawInputDeviceList)
    {
    uiCount = GetRawInputDeviceList (pRawInputDeviceList & nDevices, sizeof (RAWINPUTDEVICELIST));
    Di RID_DEVICE_INFO = {0};
    for (unsignedint iNdx = 0; iNdx)< ndevices;="" indx++="">
    {
    Memset (& di, 0, sizeof (di));
    UINT uiSizeOfDI = sizeof (di);
    UINT uiDI = GetRawInputDeviceInfo (pRawInputDeviceList [iNdx] .hDevice, & RIDI_DEVICEINFO, & uiSizeOfDI);

    di.hid.usUsage & di.hid.usUsagePage are on XP always 0.

    We use this function to find the correct values for the busy and usUsagePage of a scanner barcode for our call to RegisterRawInputDevices (.)
    I couldn't find any documentation on the correct values. The values returned on a Windows 7 PC dosometimes work on Windows XP.

    / * static * /.

    bool CBarcodeScanner_RawInput::RegisterForRawInput (HWND hWnd)
    {
    RAWINPUTDEVICE rid = {0};
    rid.dwFlags = RIDEV_INPUTSINK;
    rid.hwndTarget = hWnd;
    rid.usUsage = 0x4A00;
    rid.usUsagePage = 0xFF45;
    UINT uiRegCount = RegisterRawInputDevices (& RID, 1, sizeof (RAWINPUTDEVICE));
    Return uiRegCount > 0;
    }

    Is there a universal approach to solve this problem?

    Kind regards

    Jan Oudkerk

    Hey Jan Oudkerk,

    Your question of Windows is more complex than what is generally answered in the Microsoft Answers forums. It is better suited for the MSDN Web site. Please post your question in the MSDN forum. Link: http://social.msdn.microsoft.com/Forums/en/categories

    With regard to:

    Samhrutha G S - Microsoft technical support.

    Visit ourMicrosoft answers feedback Forum and let us know what you think.

  • CVI9.0 time (NULL) returns zero

    I just upgraded to CVI9.0 on a project and I got a zero on this curtime = time (NULL);

    time_t starttime, curtime;

    CURTIME = Time (null);
    DIF = difftime (curtime, starttime);
    This caused a Fatal run time error later in my code so program suspended in the debug window.

    In debugging the curtime value was 0.

    This program has worked well in CVI8.0.1 before the upgrade.

    Sorry my mistake. Had a bug in my software. line was bypassed.

    the Time() function is OK.

  • return zero when no data available

    Hello.


    In PL/SQL, sql next causes an error when there is no record that matches the search criteria:


    -----
    Select pin_number from table1 where id = 1;
    -----

    error: no data available


    Is there a way to get a return value 0 whenever there is no matching record?


    Any suggestions are greatly appreciated.

    Use exception NO_DATA_FOUND...

    Read FAQ: {message identifier: = 9360013}

    You can also use MAX based on your requirement... What do you do, if there are multiple records ID? Based on that you can use as

    select nvl(max(pin_number),0) from table1 where id = 1;
    
  • stored procedure returns zero results

    Hello, please help me. I'm quite new to oracle stored procedures. I have a proc that returns data to the MTC, but he keeps giving no results. But if I don't use a stored procedure, the same query gives me something. Help, please. my stored proc and cfm goes something like below:

    ************************************ stored procedures **************************************
    CREATE OR REPLACE PACKAGE IN THE PACK_REFCURSOR_NHM_TRANSACTION
    TYPE TRANS_TableRows IS REF CURSOR;
    PROCEDURE REFCUR_NHM_TRANSACTION)
    IN_sTMPACC IN varchar2,
    IN_sITEM_TYPES IN varchar2,
    OUT_TRANS to TRANS_TableRows);
    END PACK_REFCURSOR_NHM_TRANSACTION;
    /

    CREATE OR REPLACE PACKAGE BODY PACK_REFCURSOR_NHM_TRANSACTION AS
    PROCEDURE REFCUR_NHM_TRANSACTION)
    IN_sTMPACC IN varchar2,
    IN_sITEM_TYPES varchar2,
    OUT_TRANS ON TRANS_TableRows)
    IS


    BEGIN

    OPEN FOR OUT_TRANS
    SELECT T.TRANSACTION_ID, T.TRANSACTION_TYPE, T.TRANSACTION_DATE, T.TRANSACTION_TIME,
    T.ITEM_CODE, 0 OE_DETAIL_ID,
    T.QUANTITY, T.LIST_PRICE, T.DISCOUNT, T.SALE_PRICE, T.GST_AMOUNT, 'I' INSURER_TYPE
    OF NHM_TRANSACTION T
    WHERE DISPENSED_FLG = 'Y '.
    AND T.ACCOUNT_ID = IN_sTMPACC
    AND T.TRANSACTION_TYPE ('01', ' 02', ' 09')
    AND NVL (T.STATUS, 'F'). = « C »
    AND T.BILLED_FLG = N
    AND T.ITEM_TYPE IN (IN_sITEM_TYPES)
    AND T.BILL_ITEM_FLG = 'Y '.
    UNION ALL
    SELECT TRANSACTION_ID, TRANSACTION_TYPE, T.TRANSACTION_DATE, T.OE_TRANSACTION_ID
    T.TRANSACTION_TIME, NVL (T.ITEM_CODE, T.PACKAGE_CODE) ITEM_CODE, T.OE_DETAIL_ID,
    T.QUANTITY, T.LIST_PRICE, T.DISCOUNT, T.SALE_PRICE, T.GST_AMOUNT, THE OF ' INSURER_TYPE
    OF NHC_OE_TRANSACTION T, NHC_MASTER_ITEM M, NHM_PACKAGE P
    WHERE T.ACCOUNT_ID = IN_sTMPACC
    AND T.ITEM_CODE = M.ITEM_CODE (+)
    AND T.PACKAGE_CODE = P.PACKAGE_CODE (+)
    AND (DECODE (T.ITEM_CODE, NULL, P.BILL_OPTION, M.BILL_OPTION) ('P', 'O', 'F'))
    AND NVL (T.STATUS, 'F'). = « C »
    AND T.BILLED_FLG = N
    AND ((T.TRANSACTION_TYPE = ' 09 "AND STATUS IN ('P', 'R'))
    OR T.TRANSACTION_TYPE IN ('01', '02', '11', '12', 10'))
    AND T.BILL_ITEM_FLG = 'Y '.
    AND T.ITEM_TYPE IN (IN_sITEM_TYPES);


    END REFCUR_NHM_TRANSACTION;
    END PACK_REFCURSOR_NHM_TRANSACTION;


    cfm code (Note: I use coldfusion MX *)

    < datasource = "" #application.datasource # cfstoredproc "procedure =" NSCOCT. PACK_REFCURSOR_NHM_TRANSACTION. REFCUR_NHM_TRANSACTION">
    < cfprocparam type = 'IN' cfsqltype = "CF_SQL_VARCHAR" value = "' #TMPACC # ' dbvarname ="IN_sTMPACC">"
    < cfprocparam type = 'IN' cfsqltype = "CF_SQL_VARCHAR" value = "#QRYLOCITEM. "ITEM_TYPE # ' dbvarname ="IN_sITEM_TYPES">
    < name cfprocresult = "getPrescItems" >
    < / cfstoredproc >

    I getPrescItems of dumping and not return any data. It's supposed to return something. Any help is very appreciated. Thank you. *********

    I've already found the solution and it worked. I guess that's the Oracle. In any case, just in case you might need it some time, here is the link: ask Tom

  • NVL will return zero

    Hello
    I called NVL function in a select query:

    SELECT NVL(INTCO_RPX,0) in the var OF INTCO WHERE CONT_ID = 93273;

    the query does not return a result, so I expect to 0 as a result, with the nvl function
    but I make an exception, I does not return a value
    someone has an idea?


    Concerning

    SELECT INTO must return one and a single folder... Because he didn t he raised the NO_DATA_FOUND exception.

    A NVL does not change that.

  • Average return zero

    I am trying to take some readings of an oscilloscope. I made a simple VI to test all parameters for the oscilloscope and to make sure that everything worked before the implementation of the oscilloscope in a much more elaborate VI. I want to have the voltage at a certain level (say, 2 V) then take a reading from the oscilloscope, adds this value as a new item in a table. Once this 100 times the VI will add the average value in a spreadsheet and then increase the voltage (to 2.05 V or something) and take measures over 100 and average/record, them. I could take ten sets of 100 medium-sized samples and store them in a table (see notbroken.png) on a single file, but when I try to do in the actual program (see broken.png), I check my spreadsheet, and each entry is "0.000". Note that I also created a program that controls power independent and verified that I know how to control properly; Indeed, the only nonzero column is one who reads the voltage that the program is indicative of the power to the output.

    I wrote literally every step that my program 'not broken' to find the average value and then does the same for the broken program and I can't find a single gap. Any help would be greatly appreciated!

    A quick look, I think you need records to shift on your loops so that you pass the data of the previous iteration to the following.

    Lynn

  • sqcode Oracle returns '0' (zero)

    Hi all

    Can someone please tell me what is the error number 0 to pl/sql.in which situvation it will be popup?

    Thanks in advance,
    Sanjeev.

    If no exception was raised, SQLCODE return zero and SQLERRM returns the message: ORA-0000: normal completion, with success.

    Rajuvan.

  • Return to zero

    Can I have a simple select query out the expected. If the balance negative return zero return, otherwise it's. Please provide a select query to obtain the expected results


    Actual output

    Balance
    -20
    40
    50
    -60

    Results expected (if negative balance 0 return)
    Balance
    0
    40
    50
    0

    Hello

    Try this:

    SELECT     GREATEST (balance, 0)     AS balance
    FROM     table_x
    ;
    

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) and also publish outcomes from these data.
    Explain, using specific examples, how you get these results from these data.
    Always tell what version of Oracle you are using.

  • CVI division by zero defects

    Hello

    I use NI LabWindows CVI 2012.

    I have a piece very simple code:

    Double a = 4/0;

    This piece of code, I would like to return NaN, or at least do something that isn't to stop the execution on the compilation.  "Is there a way to turn NaN handling functionality or add an exception for the compiler that said: if division by zero is found, returns zero" or something?

    Here, any help would be greatly appreciated

    Hello

    It's probably doing an entire division and then by converting the result in duplicate.  Division by zero with an integer will crash your application.  I would try this:

    Double a = 4.0/0,0;

    If adding le.0 in the end tells the compiler that it is a floating point type, where division by zero is not as bad.  Moreover,.

    Double;

    a = NotANumber ();

    Can also do what you want.  If you want to check for NaN you can do something like this:

    If (IsNotANumber (a))

    a = 0.0;

  • VO return at least one row

    Hello
    I work with JDeveloper 11.1.1.6.0.

    I have a ViewObject with a ViewCritera, the criteria line returns zero or one. The result is displayed in a pop-up window. Somehow the entry field is not there. I think that it because there is no line.
    Now when it returns no rows, I want to have a line clear so I could create this entry in the database.

    I hope that my use case is clear enough.

    Thanks in advance.

    Hello

    -perform vo

    vo.executeQuery()
    

    -to obtain the estimated number of lines

    long rcount = vo.getEstimatedRowCount();
    

    -If rcompte == 0 then create line otherwise do nothing

    if(rcount == 0){
     //call createInsert operation
    }else{/*do nothing*/}
    

    -openpopup

     popup.show(new RichPopup.PopupHints());
    

    hope this helps

  • Query must return the values null

    Hi once again, everything

    The query below should return zero values for the date, but instead it brings back each transaction in the table, any ideas why?
    SELECT
    
    CID.transaction_id,
    MMT.ITEM_ORD PART_NUMBER,
    CID.DESCRIPTION,
    CID.TRANSACTION_TYPE_NAME,
    CID.LINE_TYPE_NAME,
    CID.SUBINVENTORY_CODE,
    MMT.TRANSACTION_QUANTITY,
    CID.BASE_TRANSACTION_VALUE TRANSACTION_VALUE,
    GLC.SEGMENT1,
    GLC.SEGMENT2,
    GLC.SEGMENT3,
    GLC.SEGMENT4,
    GLC.SEGMENT6,
    TO_CHAR (MMT.TRANSACTION_DATE, 'DD-MON-YY HH24:MI') transaction_date_and_time,
    TRUNC (MMT.TRANSACTION_DATE) transaction_date
    
    
    
    
    FROM
    
    CST_INV_DISTRIBUTION_DAV_V CID,
    MTL_MATERIAL_TXNS_VAL_V MMT,
    GL_CODE_COMBINATIONS GLC
    
    
    
    
    WHERE
    
    CID.TRANSACTION_ID = MMT.TRANSACTION_ID
    AND CID.REFERENCE_ACCOUNT = GLC .CODE_COMBINATION_ID;
    AND MMT.TRANSACTION_DATE = '26-AUG-11 22:00'

    Yes. It's true. You must use TO_DATE to convert a string to a date and you must use TO_CHAR to convert a date into a string.

Maybe you are looking for