Case Sensitivity

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Aug 2008
Posts: 77
Reputation: nagatron is an unknown quantity at this point 
Solved Threads: 0
nagatron nagatron is offline Offline
Junior Poster in Training

Case Sensitivity

 
0
  #1
Jan 22nd, 2009
Please help me how to ignore case sensitivity in VB. My program is to store data in the database, though I use small letters or big letters, the database store the data starting with a capital letter followed by small letters. Ex.

Input: Neil, neil, NEIL

In the database: Neil

So if I input Neil, the program response is ok but if I input neil or NEIL, the program results an error in the database and the program exits.

Please I need your kind help. Thank you so much.

Regards,
Neil
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 16,240
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 542
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator

Re: Case Sensitivity

 
0
  #2
Jan 22nd, 2009
what database are you using?

That sounds more like an issue with your DBMS as VB6 doesnt normally care about case
If i am helpful, please give me reputation points.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 77
Reputation: nagatron is an unknown quantity at this point 
Solved Threads: 0
nagatron nagatron is offline Offline
Junior Poster in Training

Re: Case Sensitivity

 
0
  #3
Jan 22nd, 2009
I am using MS Access, can you help me how to resolve this? Thank you so much. . .
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Case Sensitivity

 
0
  #4
Jan 23rd, 2009
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. SELECT * From table where LOWER(name) = 'neil'
?
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 1,114
Reputation: cguan_77 has a little shameless behaviour in the past 
Solved Threads: 91
cguan_77's Avatar
cguan_77 cguan_77 is offline Offline
Veteran Poster

Re: Case Sensitivity

 
0
  #5
Jan 23rd, 2009
hi, try this subroutine.. and use the final data to process to your database...

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1.  
  2. Sub zz()
  3.  
  4. Dim inputx, inputy, inputz, inputfinal As String
  5. Dim i As Integer
  6.  
  7. inputx = InputBox("enter data")
  8.  
  9. i = Len(inputx)
  10.  
  11.  
  12. inputy = UCase(Mid(inputx, 1, 1))
  13.  
  14. inputz = LCase(Mid(inputx, 2, i - 1))
  15.  
  16. inputfinal = inputy + inputz
  17.  
  18. MsgBox inputfinal 'use inputfinal data to process to your database
  19.  
  20.  
  21. End Sub

hope it helps...
Last edited by cguan_77; Jan 23rd, 2009 at 2:04 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 77
Reputation: nagatron is an unknown quantity at this point 
Solved Threads: 0
nagatron nagatron is offline Offline
Junior Poster in Training

Re: Case Sensitivity

 
0
  #6
Jan 23rd, 2009
Here is my sample code fragment, are there anything to be added in this code? please help me. . .thank you so much. . .
The highlight part is where the upper case and lower case error.


Private Sub cmdAdd_Click()
chec:

Set rst = New ADODB.Recordset

With rst

    .ActiveConnection = Con
    .CursorLocation = adUseClient
    .CursorType = adOpenDynamic
    .LockType = adLockOptimistic
    .Open "event"

End With

If rst.AbsolutePosition > -1 Then
    rst.MoveLast
    R_Count = rst.RecordCount
    rst.MoveFirst
    For i = 1 To R_Count
        If rst.Fields("eventname") = Trim(txtEName.Text) Then
            Label20.Caption = "Event Name Already Exist. Type a new one"
            txtEName.SetFocus
            Exit Sub
            End If
            rst.MoveNext
            Next i
            Call dataupdate2
            Else
            Call dataupdate2
End If

rst.Close
Set rst = Nothing
Call dload2
End Sub
Last edited by Narue; Jan 23rd, 2009 at 11:33 am. Reason: added code tags
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 537
Reputation: choudhuryshouvi is an unknown quantity at this point 
Solved Threads: 49
choudhuryshouvi's Avatar
choudhuryshouvi choudhuryshouvi is offline Offline
Posting Pro

Re: Case Sensitivity

 
0
  #7
Jan 23rd, 2009
what's the exact error msg you are getting????
can you be more clear on this....
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 77
Reputation: nagatron is an unknown quantity at this point 
Solved Threads: 0
nagatron nagatron is offline Offline
Junior Poster in Training

Re: Case Sensitivity

 
0
  #8
Jan 23rd, 2009
If the name already exits in the database, the message "Event Name Already Exist. Type a new one" will supposedly appear. But it only works if I input "Neil" but if I input "neil" or "NEIL", error message appear, "you can't store item because it's already exist in the database" then the 3 buttons appear "end, debug and the 3rd one (i forgot the name) will appear. What do you think is wrong with the code? Why is it this message (Event Name Already Exist. Type a new one) will not appear if I input the same name but with different letter case?

All I want is no matter what case you use, the message "Event Name Already Exist. Type a new one" should appear if it exist in the database. . .help me, thank you so much.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 537
Reputation: choudhuryshouvi is an unknown quantity at this point 
Solved Threads: 49
choudhuryshouvi's Avatar
choudhuryshouvi choudhuryshouvi is offline Offline
Posting Pro

Re: Case Sensitivity

 
0
  #9
Jan 24th, 2009
Originally Posted by nagatron View Post
If the name already exits in the database, the message "Event Name Already Exist. Type a new one" will supposedly appear. But it only works if I input "Neil" but if I input "neil" or "NEIL", error message appear, "you can't store item because it's already exist in the database" then the 3 buttons appear "end, debug and the 3rd one (i forgot the name) will appear. What do you think is wrong with the code? Why is it this message (Event Name Already Exist. Type a new one) will not appear if I input the same name but with different letter case?

All I want is no matter what case you use, the message "Event Name Already Exist. Type a new one" should appear if it exist in the database. . .help me, thank you so much.
well....frnd...msaccess doesn't care for case at all....whether you use uppercase or lowercase or mixmatched letters....msaccess recognizes all as same....but to avoid getting this error you can modify your code....just a sample here....you can check this out...

just write a private function with return type of boolean, pass the event name which you need to check for duplication as parameter

now on a button_click event, accept an event name from a textbox, call the function and if it returns true then show your msg....that's it....so simple...

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Function IsEventExists(ByVal evtName As String) As Boolean
  2. Dim gcn As New ADODB.Connection
  3. Dim rs As New ADODB.Recordset
  4.  
  5. On Error GoTo err1
  6.  
  7. If gcn.State = adStateOpen Then gcn.Close
  8. Set gcn = Nothing
  9.  
  10. gcn.ConnectionString = "<your connection string>"
  11. gcn.Open
  12.  
  13. rs.CursorLocation = adUseClient
  14. rs.CursorType = adOpenDynamic
  15. rs.LockType = adLockOptimistic
  16. rs.Open "select * from <your tablename> where <your field name>='" & Trim(evtName) & "'", gcn
  17.  
  18. If rs.RecordCount > 0 Then
  19. IsEventExists = True
  20. Else
  21. IsEventExists = False
  22. End If
  23.  
  24. If rs.State = adStateOpen Then rs.Close
  25. Set rs = Nothing
  26.  
  27. Exit Function
  28.  
  29. err1:
  30. Err.Clear
  31. IsEventExists = True
  32. Exit Function
  33. End Function
  34.  
  35. Private Sub Command1_Click()
  36. If IsEventExists(Text1.Text) = True Then
  37. MsgBox "Event Name Already Exist. Type a new one", vbInformation, "Duplicate Event"
  38. Text1.SetFocus
  39. Else
  40. '''insert it to the database...put the code here
  41. End If
  42. End Sub


get me a feed if this works out for you...

regards
Shouvik
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 77
Reputation: nagatron is an unknown quantity at this point 
Solved Threads: 0
nagatron nagatron is offline Offline
Junior Poster in Training

Re: Case Sensitivity

 
0
  #10
Jan 24th, 2009
This is what I did:

Private Function IsEventExists(ByVal evtName As String) As Boolean

Dim gcn As New ADODB.Connection
Dim rst As New ADODB.Recordset

On Error GoTo err1

If gcn.State = adStateOpen Then gcn.Close
Set gcn = Nothing

gcn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & App.Path & "\facility.mdb"

gcn.Open

    rst.CursorLocation = adUseClient
    rst.CursorType = adOpenDynamic
    rst.LockType = adLockOptimistic
    rst.Open "select * from event where eventname='" & Trim(txtEName) & "'", gcn

If rst.RecordCount > 0 Then
    IsEventExists = True
Else
    IsEventExists = False
End If


If rst.State = adStateOpen Then rst.Close
Set rst = Nothing

Exit Function

err1:
    Err.Clear
    IsEventExists = True
    Exit Function
End Function

-------------------------------------------------------------------------------------

Private Sub cmdAdd_Click()
chec:

Set rst = New ADODB.Recordset

With rst

    .ActiveConnection = Con
    .CursorLocation = adUseClient
    .CursorType = adOpenDynamic
    .LockType = adLockOptimistic
    .Open "event"

End With

If IsEventExists(txtEName.Text) = True Then
    MsgBox "Event Name Already Exist. Type a new one", vbInformation, "Duplicate Event"
    txtEName.SetFocus
Else
With rst

.AddNew
.Fields!fnumber = StrConv(txtFNumber, vbProperCase)
.Fields!eventname = StrConv(txtEName, vbProperCase)
.Fields!fname = StrConv(txtFName, vbProperCase)
.Fields!fincharge = StrConv(txtFIncharge, vbProperCase)
.Fields!fschedules = StrConv(Text2, vbProperCase)
.Fields!fschedulee = StrConv(Text3, vbProperCase)
.Fields!sitcapacity = StrConv(txtCapacity, vbProperCase)
.Fields!userschede = StrConv(Combo4, vbProperCase)
.Fields!userscheds = StrConv(Combo3, vbProperCase)
.Fields!fuser = StrConv(txtFUser, vbProperCase)
.Fields!destination = StrConv(txtDestination, vbProperCase)
.Fields!condition = StrConv(cboCondition, vbProperCase)
.Fields!enddate = dtpDate(0).Value
.Fields!startdate = dtpDate(0).Value
.Fields!transaction = StrConv(cboTransaction, vbProperCase)
.Fields!fsh = StrConv(txtfsh, vbProperCase)
.Fields!ush = StrConv(txtush, vbProperCase)
.Update
Label20.Caption = "Successfully Saved. . ."
End With
End If
Call dload2
End Sub


OUTPUT: "Event Name Already Exist. Type a new one" this messge always pop-up even I put a new event name. what do you think is wrong with my code?
The "dload2" there is where the data display in the MSFlexGrid. What am I going to put in the "gcn.ConnectionString="<?>"?
Last edited by nagatron; Jan 24th, 2009 at 9:13 am.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC