U
UsenetUser
This is so easy in VBA, but every source I research to do it in vb.net
seems to have a more difficult and convoluted method involving
datasets, tableadapters, etc. etc. What's the easiest way to open a
recordset and pull over one record like this with vb.net?
Public Function fnGetName(IDS As Integer) As String
Dim rs As ADODB.Recordset
Dim strSQL As String
Dim strName As String
'On Error GoTo procError
strSQL = "SELECT * FROM tblPatient WHERE PatientIDS = " & IDS
Set rs = New ADODB.Recordset
With rs
.Open strSQL, CurrentProject.Connection, adOpenForwardOnly
If .EOF And .BOF Then
'
Else
strName = !Lname
If Not IsNull(!fname) Then strName = strName & ", " & !fname
End If
.Close
End With
fnGetName = strName
End Function
seems to have a more difficult and convoluted method involving
datasets, tableadapters, etc. etc. What's the easiest way to open a
recordset and pull over one record like this with vb.net?
Public Function fnGetName(IDS As Integer) As String
Dim rs As ADODB.Recordset
Dim strSQL As String
Dim strName As String
'On Error GoTo procError
strSQL = "SELECT * FROM tblPatient WHERE PatientIDS = " & IDS
Set rs = New ADODB.Recordset
With rs
.Open strSQL, CurrentProject.Connection, adOpenForwardOnly
If .EOF And .BOF Then
'
Else
strName = !Lname
If Not IsNull(!fname) Then strName = strName & ", " & !fname
End If
.Close
End With
fnGetName = strName
End Function