flaniganmj
Technical User
I use the below often; however, I have been unable to convert it to VB.NET. Mainly, I want to create a new record and capture the int identity record value for further use.
I have not been able to find anything in these forums; so, any help (or pointing me in the right direction) would be appriciated.
Regards,
mjf
Code:
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strcn As String
Dim strsql As String
Try
strcn = "provider=sqloledb;integrated security=SSPI;data source=LONGS;initial catalog=AFD"
strsql = "select * from tcmm_creditmemo where creditmemokey=0"
With cn
.ConnectionString = strcn
.ConnectionTimeout = 1000
.Open()
End With
rs.Open(strsql, cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)
With rs
.AddNew()
.Fields("InvNo").Value = ""
.Update()
CreateNewRecord = .Fields("CreditMemoKey").Value
End With
Catch x As Exception
MsgBox(x.Message, mbtErr, sErrTitle)
CreateNewRecord = 0
Finally
rs = Nothing
cn = Nothing
End Try
I have not been able to find anything in these forums; so, any help (or pointing me in the right direction) would be appriciated.
Regards,
mjf