I use to write queries in VB6 to retrieve data and manipulate like this:
Public Function GetInvoiceHdrID(lInvNo) As Long
Dim sSQL As String
Dim rst As ADODB.Recordset
Dim Conn As ADODB.Connection
On Error GoTo ErrorHandler
Set rst = New ADODB.Recordset
Set Conn = New ADODB.Connection
Conn.ConnectionString = gsConnStr
Conn.CursorLocation = adUseClient
Conn.ConnectionTimeout = 60
Conn.Open
sSQL = "Select InvHdrID from tblInvHdr where InvoiceNo = " & lInvNo
rst.Open sSQL, Conn, adOpenForwardOnly, adLockReadOnly
If rst.RecordCount > 0 Then
GetInvoiceHdrID = rst("InvHdrID")
Else
GetInvoiceHdrID = 0
End If
Set rst = Nothing
Conn.Close
Set Conn = Nothing
Exit Function
How can I do stuff like this with VB.net?
Thanks
Public Function GetInvoiceHdrID(lInvNo) As Long
Dim sSQL As String
Dim rst As ADODB.Recordset
Dim Conn As ADODB.Connection
On Error GoTo ErrorHandler
Set rst = New ADODB.Recordset
Set Conn = New ADODB.Connection
Conn.ConnectionString = gsConnStr
Conn.CursorLocation = adUseClient
Conn.ConnectionTimeout = 60
Conn.Open
sSQL = "Select InvHdrID from tblInvHdr where InvoiceNo = " & lInvNo
rst.Open sSQL, Conn, adOpenForwardOnly, adLockReadOnly
If rst.RecordCount > 0 Then
GetInvoiceHdrID = rst("InvHdrID")
Else
GetInvoiceHdrID = 0
End If
Set rst = Nothing
Conn.Close
Set Conn = Nothing
Exit Function
How can I do stuff like this with VB.net?
Thanks