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
Solved

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

Posted on 2006-07-07
7
2,455 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

839 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