I am trying to save my scale configurations in the database so first I have to check if it exists in the database.and I am using the code below to do that . however when there is no data in the database I will get an error "No row at position 0" or when the scale number is not there i will get the same error. can anyone help?
Dim dTable As DataTable = New DataTable
Dim Sql As String = "select ScaleNumber from Scale where ScaleNumber = '" & cmbScaleNumber.Text & "' "
'Dim cmd As New OleDbCommand(iSql, Conn)
Dim da As New OleDbDataAdapter(Sql, Conn)
da.Fill(dTable)
If dTable.Rows.Count = 0 Then
If dTable.Rows(0)("ScaleNumber") = cmbScaleNumber.Text Then
MsgBox("The Scale is configured")
Exit Sub
End If
Else
MsgBox("Nice one")
End If