Solved

Run-time error '-2147467259 (80004005)': Unspecified error

Posted on 2006-07-07
7
2,425 Views
Last Modified: 2008-01-09
Hi all,
  I am using Vb6.0 with SQL Server 7.0.
The code is below
If rSetQuery.EOF Then
        If rSetQuery.State <> adStateClosed Then rSetQuery.Close
        mySql = "Select Top 50 * from FDHS WHERE CustomerName >'" & Trim(tdbtName) & "' Order By Customername,Trxdate"
        rSetQuery.Open mySql, Con
End If
When run this query in SQL Server Enterprise manager I can get the top 50 results.
When I run in the vb6.0 I am getting the error
Run-time error '-2147467259 (80004005)':
Unspecified error
The fieldname CustomerName is varchar 75. tdbtname is the textbox control in the VB.
Can anyone help me to solve this problem asap.
Thanks & Regards,
K.Siva.
0
Comment
Question by:siva2k
  • 2
7 Comments
 
LVL 35

Expert Comment

by:Raynard7
ID: 17057102
How is the con connected? it is not set in  your code - this is often a cause for errors;

also - is tdbtName escaped - ie could it contain a ' ? which would ruin the code.

If you get to the rSetQuery.Open mySql, Con line and break on it  - then copy the value for mySql, does this run in enterprise manager?

Also - where is the error occuring?
0
 

Author Comment

by:siva2k
ID: 17057574
Con is connected as per normal.
I have escaped tdbtName.
I run the mySQL is enterprise manager I can get the result.
I am getting the error at
rSetQuery.Open mySql, Con
0
 
LVL 29

Accepted Solution

by:
leonstryker earned 50 total points
ID: 17058529
Try this:

        If rSetQuery.State <> adStateClosed Then rSetQuery.Close

        mySql = "Select Top 50 * from FDHS WHERE CustomerName >'" & Trim(tdbtName) & "' Order By Customername,Trxdate"
        Debug.Print mySql

        rSetQuery.Open mySql, Con, adOpenStatic, adLockOptemistic

It is a good idea to print out the SQL into the Immediate window during debugging just to see what you are passing to the database.  

I think your problem is with this part CustomerName >'" & Trim(tdbtName) & "' .  I am pretty sure the driver does not like the > operator with a text datatype.

Leon
0
 
LVL 35

Assisted Solution

by:Raynard7
Raynard7 earned 50 total points
ID: 17077215
I agree about seeing the SQL;

The error number relates to unparseable SQL  -  I am wondering if you can post the result of mySql - so we can see what the issue is I agree with leon - I think that this value is the problem - tdbtName you say is escaped - are you using the mySql dll for that?
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now