473,405 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How To Validate Duplicate Id Number In Client Server?

3
Hi To All.... This Is My First Try To Create A Program Which Compose A Server And 2 Client...i Use Access Database As My Back End And Vb6 As My Front End...

Problem
1. I Create A Code In Which A User Can Generate Autonumber
But The Problem Is If Two Clients Input Together It Would
Both Save The Data To The Server With A Duplicate And
Same Id Number...

This Is My Code Which I Generate Auto Number.....

Dim Rs As New Adodb.recordset
Set Rs=cn.execute("select Max(fieldname) From Tblname)
If Isnull(rs(0))=true Then
Idnum=1
Else
Idnum=rs(0)+1
Endif

Please Help Me..... How Can I Validate Idnum Before It Save To Server?....
tnx...
Feb 9 '08 #1
3 2277
werks
220 100+
HI this is my code in Validating the username of the Librarian


Expand|Select|Wrap|Line Numbers
  1. Dim ExistUserName AS Boolean
  2. Private Sub cmdSave_Click()
  3. ...
  4.     Call VerifyUserName
  5.     If ExistUserName = True Then
  6.         MsgBox "Username exist please choose aanother", 48, "Username Existing"
  7.         Exit Sub
  8.     End If
  9. ...
  10. End Sub
  11.  
  12.  
  13. Private Sub VerifyUserName()
  14.     Dim rsUserList As New ADODB.Recordset
  15.     'ASSUMING THAT THE USERNAME IS NOT EXISTING
  16.     ExistUserName = False
  17.     'OPEN THE STUDENT TABLE
  18.     rsUserList.Open "SELECT * FROM tblUser WHERE Username='" & txtName(7).Text & "'", CoNN, 3, 3
  19.     'CHECK IF THE ID NUMBER IS ALREADY EXIST
  20.     If rsUserList.RecordCount > 0 Then
  21.         ExistUserName = True
  22.     End If
  23.  
  24.     rsUserList.Close
  25.     Set rsUserList = Nothing
  26.  
  27. End Sub
  28.  
  29.  
Hope this help..
Feb 10 '08 #2
mafaisal
142 100+
Hello Werks

I think this is not good
if we edit some thing then save then duplication error is coming using this code
Better way is use Primary key and Unique key constarint for duplication
Also this code
use verifyusename as function return type boolean, then we can avoid extra var for

Faisal

HI this is my code in Validating the username of the Librarian


Expand|Select|Wrap|Line Numbers
  1. Dim ExistUserName AS Boolean
  2. Private Sub cmdSave_Click()
  3. ...
  4.     Call VerifyUserName
  5.     If ExistUserName = True Then
  6.         MsgBox "Username exist please choose aanother", 48, "Username Existing"
  7.         Exit Sub
  8.     End If
  9. ...
  10. End Sub
  11.  
  12.  
  13. Private Sub VerifyUserName()
  14.     Dim rsUserList As New ADODB.Recordset
  15.     'ASSUMING THAT THE USERNAME IS NOT EXISTING
  16.     ExistUserName = False
  17.     'OPEN THE STUDENT TABLE
  18.     rsUserList.Open "SELECT * FROM tblUser WHERE Username='" & txtName(7).Text & "'", CoNN, 3, 3
  19.     'CHECK IF THE ID NUMBER IS ALREADY EXIST
  20.     If rsUserList.RecordCount > 0 Then
  21.         ExistUserName = True
  22.     End If
  23.  
  24.     rsUserList.Close
  25.     Set rsUserList = Nothing
  26.  
  27. End Sub
  28.  
  29.  
Hope this help..
Feb 10 '08 #3
debasisdas
8,127 Expert 4TB
1.Make the auto number field your primary key. It won't accept duplicate value.
or
2.You can check for existence of the record using count and then insert the record if that does not exist already in database.
Feb 11 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: varois83 | last post by:
Hi Newbie here. I have been working on creating a guestbook for my site as practice and am learning a lot. Do you guys validate your forms first on the client with javascript and then on the...
5
by: Andrew | last post by:
Hi, How can I validate a date, like 3/26/04, before submitted? Thanks for any idea. -- Andrew
0
by: Gary Lundquest | last post by:
I have an application with MS Access 2000 as the front end and MySQL as the back end. All was well until I upgraded the MySQL (Linux) server. The Problem: I insert data into a cumulative table....
24
by: Arno R | last post by:
Hi all, I have a client with several shoe-shops. Customers can leave their email-address if they want to be notified when there is a sale. Input is validated with instr() I am checking for @...
3
by: Mike Logan | last post by:
How do I validate messages? If my schema has a simpleType with facets like "minExclusive" and "maxLength" will the .Net framework validate the message before running the web service? This is what...
0
by: Jay Douglas | last post by:
Hello all, I'm in need of a custom validator that: 1). Runs server side code using ajax through a client validate function 2). Client validate function does not set args.IsValid until the...
8
by: sixdeuce62 | last post by:
Hello, I am using Access 2002. I have read through 20 plus posts on here and I am still having trouble. My table consists of the following fields: Date Client ID
26
by: webrod | last post by:
Hi, I have some php pages with a lot of HTML code. I am looking for a HTML validator tool (like TIDY). TIDY is not good enough with PHP tags (it removes a lot of php code). Do you have any...
6
by: Steve Ryan | last post by:
can anyone send me to some good examples of edit in place for data frid columns i see dot net let me assign a control in the IDE any good sources of reading on editing columns with controls...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.