Crea un nuovo db con un solo campo che nomini Nome, per provare
Metti nel progetto un modulo.bas e incolla questo:
Global g_strConnectionString As String
poi fai così:
Private Sub cmdInvia_Click()
'incolla questo come prima linea del pulsante
g_strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
& App.Path & "\NomeDelTuoDB.mdb; Persist Security Info=False"
'il DB deve stare nella directory del progetto vb
'ora g_strConnection contiene il riferimento alla connessione
Dim dbConnAs New ADODB.Connection
Dim strConnectionString As String
Dim strSQL As String
Dim iNome As String
iNome = txtNome
If txtNome = "" Then
MsgBox "Inserisci i campi obblibatori * mancanti", vbInformation
exit sub
end if
'Apro una connessione con il database
dbConn.ConnectionString = g_strConnectionString
dbConn.Open
Dim bRes As Boolean
bRes = controllanome(iNome, dbConn)
If bRes = True Then
beep
MsgBox ("iNome già presente")
dbConn.Close
Set dbConn = Nothing
else
strSQL = "INSERT INTO Tabella (Nome) VALUES ('" & iNome & "',"')"
'Tabella è il nome della tabella del tuo db
'Nome è il campo
'chiudi la connessione al database
dbConn.Close
Set dbConn = Nothing
endif
Questa è la funzione per verificare se iNome esiste già
Private Function controllanome (ByVal nome1 As String, ByRef dbConn As ADODB.Connection) As Boolean
Dim dbRec As New ADODB.Recordset
Dim strSQL As String
strSQL = "SELECT * FROM Tabella WHERE Nome = '" & nome1 & "'"
DoEvents
Set dbRec = dbConn.Execute(strSQL)
controllanome = Not dbRec.EOF
Set dbRec = Nothing
End Function
prova e fammi sapere.............
link
homepage http://%77%77%77%2e%74%77%6f%72%6b%2e%69%74/
forum http://%77%77%77%2e%74%77%6f%72%6b%2...um/default.asp