desperateboy
Active member
- Joined
- Dec 11, 2007
- Messages
- 30
- Programming Experience
- Beginner
hi friends,
I have added 3 buttons of name add,save and delete.When add username in the database first heck out that already exist or not.If not existed then insert into database.I trying using this code
Plz help to sort it out.
I have added 3 buttons of name add,save and delete.When add username in the database first heck out that already exist or not.If not existed then insert into database.I trying using this code
Plz help to sort it out.
VB.NET:
Try
Dim str1 As String
str1 = txtusr.Text
conn.Open()
cmd = New SqlCommand("select * from usrs where uname='" & (str1) & "'", conn)
dr = cmd.ExecuteReader
While dr.Read()
Str = dr.Item("uname")
If Str <> Trim(str1) Then
usrexist()
Exit Sub
Else
Dim sYN As String
sYN = MsgBox("User Already Exists, Want to Update", vbYesNo + vbQuestion, "Update User")
If sYN = vbYes Then
'' update in the database''
End If
End While
Catch ex As Exception
MsgBox(ex.Message)
Finally
cmd = Nothing
conn.Close()
dr.Close()
End Try
Last edited by a moderator: