|
-
Nov 10th, 2005, 05:23 PM
#1
Thread Starter
Addicted Member
ADO - EXCEL problem
Hi all,
I am creating very simple database in excel and I would like to implement simple searching mechanism using ADO.
To achieve this aim I wrote such a piece of code:
VB Code:
Dim search_result As String
search_result = "'%" & frmsearch.TextBox1.Text & "%'"
Dim rec As ADODB.Recordset
Dim conn As ADODB.Connection
Set conn = New ADODB.Connection
conn.Provider = "Microsoft ole db provider for odbc drivers"
conn.ConnectionString = "driver={microsoft excel driver (*.xls)};dbq=" & _
ThisWorkbook.Path & "\film_catalog.xls;"
conn.Open
Set rec = New ADODB.Recordset
rec.CursorLocation = adUseClient
rec.Open "select * from [catalog$] where category like " & (search_result), conn, adOpenDynamic, adLockOptimistic
but I have such a problem: excel doesn't ignore size of chars.
for exmaple: when I want to search a film category horror so I type horror but in database I have Horror so that I get empty recordset.
I was trying to use Option Compare Text but it doesn't work,
How can I make excel ignoring char's size???
please help
thx in advance for your help
regards,
sweet_dreams
-
Nov 10th, 2005, 11:10 PM
#2
New Member
Re: ADO - EXCEL problem
I couldn't duplicate this behavior. What versions are you using?
Anyways, one option might be to convert everything to uppercase:
VB Code:
search_result = "'%" & UCase(frmsearch.TextBox1.Text) & "%'"
rec.Open "select * from [catalog$] where UCase(category) like " & (search_result), conn, adOpenDynamic, adLockOptimistic
HTH
-
Nov 11th, 2005, 05:21 AM
#3
Frenzied Member
Re: ADO - EXCEL problem
sweet dreams:
Perhaps this Web site would help you?
http://www.excel-vba.com/e-database-functions.htm
-
Nov 12th, 2005, 04:49 PM
#4
Thread Starter
Addicted Member
Re: ADO - EXCEL problem
Hi guys,
Thanks a lot for your reply but unfortunatelly your advices didn't help.
Can anybody help me with this problem???
regards,
sweet_dreams
-
Nov 12th, 2005, 04:52 PM
#5
Re: ADO - EXCEL problem
Post #2's code should work for you. Did you get any errors and what were the results of the search?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Nov 12th, 2005, 05:04 PM
#6
Thread Starter
Addicted Member
Re: ADO - EXCEL problem
RobDog888,
I am sorry post #2's code works perfect.
But now I am trying to do it another way. Instead of
I would like to use variable. I mean:
rec.Open "select * from [catalog$] where " & UCase(variable_category) & " like " & (search_result), conn, adOpenDynamic, adLockOptimistic
and in this case this code doesn't work. excel doesn't ignore char's size.
what should I do now???
please help
regards,
sweet_dreams
-
Nov 12th, 2005, 05:07 PM
#7
Re: ADO - EXCEL problem
Instead of doing it in-line try setting the variable to ucase before hand.
VB Code:
Dim variable_category as string
variable_category = "SomeThing"
variable_category = UCase$(variable_category)
rec.Open "select * from [catalog$] where " & variable_category & " like " & (search_result), conn, adOpenDynamic, adLockOptimistic
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Nov 12th, 2005, 05:47 PM
#8
Thread Starter
Addicted Member
Re: ADO - EXCEL problem
unfortunately it also doesn't work
-
Nov 12th, 2005, 06:44 PM
#9
Re: ADO - EXCEL problem
Are youtring to search numeric and textual data types?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|