Wrox Programmer Forums
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 23rd, 2009, 06:12 PM
Authorized User
 
Join Date: Nov 2005
Posts: 15
Thanks: 5
Thanked 0 Times in 0 Posts
Default SQL query with LIKE not working

Hi
I am getting the following Automation error message when ever I use the following SQL Query in my VB6 program

Select * from Win32_NTLogEvent where message like '%something%'


Run-time error '-2147217385 (80041017)':
Automation error


but it is working with Select * from Win32_NTLogEvent where message = "something"

Can anybody tell me why this is coming.
Do I need to use any Project Reference, if so which one?

Thanks in advance

Jack
 
Old March 23rd, 2009, 06:35 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi...

What kind of database are you querying??
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old March 23rd, 2009, 10:58 PM
Authorized User
 
Join Date: Nov 2005
Posts: 15
Thanks: 5
Thanked 0 Times in 0 Posts
Default

SQL Server 2000
 
Old March 23rd, 2009, 11:04 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Does the first query by itself works inside SQL 2000?? It's a weird error, looks like the query is wrong, but it seems to be correct.
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old March 24th, 2009, 12:19 AM
Authorized User
 
Join Date: Nov 2005
Posts: 15
Thanks: 5
Thanked 0 Times in 0 Posts
Default

Hi gbianchi,

I did not tried inside the SQL Server because my query gets the event logs on the application server with the given criteria.
My program was written in vb6 which queires the event logs and display the results.

It is working fine if i am not using LIKe keyword in my query.

But when ever I use the query with LIKE it is giving me an Automation error.

Thanks


 
Old March 24th, 2009, 12:44 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

well, never see a problem like that. obviously is a problem with the LIKE, but I really don't know what to tell you. Unless you can try it inside SQL, I don't think I have anything for you.
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old March 24th, 2009, 02:49 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Are the event logs *IN* the SQL Server DB?? Or are they in something like LDAP, external to the DB but accessible via a query, anyway??

I know that LDAP queries can't make use of the full range of SQL constructs that queries against an actual database can.
 
Old March 24th, 2009, 06:48 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

The name Win32_NTLogEvent seems to suggest you're executing WMI queries against Windows, rather than SQL Server.

Is that the case? Or is it just a coincidence?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
jack_3 (March 26th, 2009)
 
Old March 24th, 2009, 05:13 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Yeah, WMI...I couldn't remember the acronym. That's what I was referring to, also. Thanks, Imar!

Anyway, I would assume that WMI doesn't allow use of LIKE, so then it all makes sense.
The Following User Says Thank You to Old Pedant For This Useful Post:
jack_3 (March 26th, 2009)
 
Old March 24th, 2009, 05:22 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You're welcome.... And I also think you can't use a LIKE statement:
Quote:
Queries can use the WHERE clause for extension and customization, although it is not required. The WHERE clause is made up of a property or keyword, an operator, and a constant. All WHERE clauses must specify one of the predefined operators that are included in WQL. For more information about syntax, see WHERE Clause. For more information about valid WQL operators, see WQL Operators.
http://msdn.microsoft.com/en-us/library/aa392902.aspx
http://msdn.microsoft.com/en-us/libr...54(VS.85).aspx

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
jack_3 (March 26th, 2009)





Similar Threads
Thread Thread Starter Forum Replies Last Post
sql query not working !! SPadmalwar SQL Server 2000 5 July 15th, 2006 12:41 AM
Delete query not working Mitch PHP Databases 4 January 4th, 2006 08:00 AM
Delete Query not working kbonney98 Access 1 April 14th, 2005 06:29 AM
Help to expand a working query mat41 SQL Language 6 February 10th, 2005 05:10 AM
Query String not working!!!!!!! cmiller Beginning PHP 1 December 16th, 2003 12:30 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.