Solved

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

Posted on 2006-07-07
7
2,481 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

690 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