PB5.31; ADOmate; @@IDENTITY; MS SQL Server;

Windows specific forum
HanPBF
Enthusiast
Enthusiast
Posts: 570
Joined: Fri Feb 19, 2010 3:42 am

PB5.31; ADOmate; @@IDENTITY; MS SQL Server;

Post by HanPBF »

Hello,

as PureBasic does not natively support connection to Microsoft SQL Server nor ORACLE database, I use for a SQL Server connection ADOmate.

When I insert a row into a table leaving ID off cause it is an identity field, how can I get the last number generated.

I tried calling ADOmate_DatabaseQuery with "select @@IDENTITY" after inserting data, but got no correct answer (only type mismatch error).
A convert lead to NULL only.

Does someone ran into this problem before?

Thanks in advance,
regards
swan
Enthusiast
Enthusiast
Posts: 226
Joined: Sat Jul 03, 2004 9:04 am
Location: Sydney Australia
Contact:

Re: PB5.31; ADOmate; @@IDENTITY; MS SQL Server;

Post by swan »

This is how I did it:

Code: Select all

          If ADOmate_DatabaseQuery(MSSQL_Connection, "SELECT @@IDENTITY AS 'ID' From dbo.positions", #adOpenStatic)
            sw_positionID.l = ADOmate_GetDatabaseLong(MSSQL_Connection, 0)
          EndIf
Post Reply