chat database help
chat database help
chat database help
chat database help
chat database help
chat database help chat database help chat database help chat database help chat database help chat database help chat database help chat database help
chat database help chat database help
chat database help
Go Back  Xtreme Visual Basic Talk > > > chat database help


Reply
 
Thread Tools Display Modes
  #1  
Old 05-23-2005, 11:45 PM
Fullyloaded Fullyloaded is offline
Centurion
 
Join Date: Mar 2005
Posts: 165
Default chat database help


hi
i was wondering if anyone can help me with my code?its a sign up for my chat witch works fine and will add the username i make up to the database but!!!when i go to make the same name again it will say username Has Been Created what im trying to do is put in the error handling so that if the username is already in the database it will say name is already taken!!can anyone help???
here is the code for the client
Code:
Private Sub Command1_Click() On Error Resume Next If Text1.Text = "" Then MsgBox "Can't Create User Account, No ScreenName Entered!", vbCritical, "Account Creation Error" Exit Sub End If If Text2.Text = "" Then MsgBox "Can't Create User Account, No Password Entered!", vbCritical, "Account Creation Error" Exit Sub End If If Text3.Text = "" Then MsgBox "Please confirm password!", vbCritical, "Account Creation Error" Exit Sub End If If Text3.Text = Text2.Text Then Winsock1.SendData (".NewUser" & " " & LCase(Text1.Text) & " " & LCase(Text2.Text)) Exit Sub Else MsgBox "your passwords do not match!" End If End Sub Private Sub Command2_Click() On Error Resume Next Unload Me End Sub Private Sub Form_Load() On Error Resume Next Winsock1.Close Winsock1.RemoteHost = "00.00.00.00" Winsock1.RemotePort = "6062" Winsock1.Connect End Sub Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) On Error Resume Next Winsock1.GetData ".UserAdded" MsgBox "User " & Text1.Text & " Has Been Created", voOKOnly, "Server Message" Text1.Text = "" Text2.Text = "" Text3.Text = "" End Sub code for the server Private Function new_User(username As String, Password As String) On Error Resume Next Dim Rs As New ADODB.Recordset Dim sConnString As String Dim conn As New ADODB.Connection sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & "\mdbAccess.mdb;" conn.Open sConnString Rs.Open "INSERT INTO Users ([username], [Password]) VALUES('" + _ CStr(username) + "', '" + _ CStr(Password) + "') ", conn Winsock1.SendData ".UserAdded" Set Rs = Nothing Set conn = Nothing End Function Private Sub winsock1_DataArrival(ByVal bytesTotal As Long) On Error Resume Next Dim strIncoming As String Winsock1.GetData strIncoming If Word(strIncoming, 1) = ".NewUser" Then Call new_User(Word(strIncoming, 2), Word(strIncoming, 3)) End If End Sub Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long) On Error Resume Next Winsock1.Close Winsock1.Accept requestID RichTextBox1.SelColor = vbBlue RichTextBox1.SelText = Now & ": Connection Request From " & Winsock1.RemoteHostIP & vbCrLf End Sub Private Sub Winsock1_Close() On Error Resume Next RichTextBox1.SelColor = vbRed RichTextBox1.SelText = Now & ": Connection Closed From " & Winsock1.RemoteHostIP & vbCrLf Call Command1_Click End Sub
thanks...

Last edited by 00100b; 05-24-2005 at 06:06 AM. Reason: Added VB Tags
Reply With Quote
  #2  
Old 05-24-2005, 09:35 AM
lebb's Avatar
lebbchat database help lebb is offline
Disillusioned Code Poet

Retired Moderator
* Guru *
 
Join Date: Apr 2002
Location: Tennessee, USA
Posts: 12,808
Default

Well, On Error Resume Next will simply ignore all errors. Have a look at the On Error statement in MSDN, and you will find examples of how to handle errors. Then if you're still having trouble, post back with the section you're having trouble with (probably just the new_User function; we don't need to see the whole module) and we can help.

Do you already have a unique constraint or primary key on the database which will prevent duplicate usernames?
__________________
Laura

Ita erat quando hic adveni.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
chat database help
chat database help
chat database help chat database help
chat database help
chat database help
chat database help chat database help chat database help chat database help chat database help chat database help chat database help
chat database help
chat database help
 
chat database help
chat database help
 
-->