با سلام
میتونی از این نمونه کد استفاده کنی .
Public Class Form1
Private cnnstring As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLED B.4.0;Data Source=|DataDirectory|\db.mdb")
Private Function ExistRecord(ByVal fieldname As String) As Boolean
Dim ap As New OleDb.OleDbDataAdapter("Select " & fieldname & " from table1 where " & fieldname & " ='" & txt1.Text & "'", cnnstring)
Dim dt As New DataTable
ap.Fill(dt)
If dt.Rows.Count = 0 Then
Return True
Else
Return False
End If
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If ExistRecord("fname") Then
MsgBox("کاربری با این نام یافت نشد", MsgBoxStyle.Information)
Else
MsgBox("کاربری با این نام قبلا ثبت شده است", MsgBoxStyle.Exclamation)
End If
End Sub
End Class
موفق باشید ./