ADO to ADO.NET - Retrieve the AutoIncrement or Identity value of a column

L

Loren Dummer

Hello All,

I am converting a VB6 application to .Net and having problems converting the
following code.


VB6 Code:

Dim lDataID as Long

sSql = "SELECT * " & _
"FROM MSMQData"

Set adoRs = New ADODB.Recordset
With adoRs

.Open sSql, adoCn, adOpenKeyset, adLockOptimistic, adCmdText

.AddNew

!XMLData = objDOM.xml

.Update

lDataID = !DataID

.Close
End With
Set adoRs = Nothing


I can get this to work using a SQLCommand object and pass back the
@@Identity value in an Output parameter with the stored procedure.

I cannot figure out what I should be using to convert this correctly.

Any help is appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top