How do you test a record to see if it is the last record? I want to append one string to the end of my script string if the record is the last one, and a continue string if it is not.
I'm showing the entire procedure below so that you guys can get a full understanding of what I'm trying to achieve.
Private Sub BuildScript()
'Build the SQL script to add the customers previously stored in the CUSTOMERS table
Dim SelectString As String = "SELECT CustNum FROM Customers WHERE Location = " & LocationCode
Dim ODBCCon As New OleDbConnection(Testing_ODBC_ConnectionString)
Dim ODBCCommand As New OleDbCommand(SelectString, ODBCCon)
ODBCCon.Open()
Dim r As OleDbDataReader = ODBCCommand.ExecuteReader
ScriptString = StartScript 'Start with beginning of script
While r.Read
AddCustomer(r(2)) 'Add customer pulled from database
'if record is the last record
'End While 'exit loop
'else
ScriptString = ScriptString & ScriptContinue 'Format script to continue adding customers
'endif
End While
ScriptString = ScriptString & EndScript 'Append end of Script
MessageBox.Show(ScriptString)
End Sub