Question

SQLSTATE 22005 error code - Invalid character value in cast specification

Asked by: kathotia

I have a data window which has as stored procedure as its data source. The parameter passed to the stored procedure is of type datetime. In the datawindow design mode and when previewing, the data is properly retrieved on entering the datetime parameter.

However when this datawindow control is embeded in a window and data is retrieved by passing a datetime parameter through script, the retrieve fails and the error mentioned as below is displayed

Select Error: SQLSTATE =22005
[Microsoft][ODBC SQL Server Driver] Invalid character value for cast specification

I am unable to resolve the problem. I am using PB10 eval version. Please help

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2005-05-25 at 04:04:28ID21436015
Tags

22005

,

sqlstate

,

character

,

cast

,

value

Topic

PowerBuilder Programming Language

Participating Experts
3
Points
250
Comments
14

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Integrity check job fails: sqlmaint.exe SQLSTATE 420…
    Integrity check job fails with message sqlmaint.exe [SQLSTATE 4200] [Error 22029]. The step failed.
  2. Cast problem :  SYSIBM.INTERGER can't be cast into S…
    Hi All, I'm migrating a database from SQL Server 2k to UDB DB2 for windows (version 8.1). I have a big problem on how to convert an integer to varchar. ...... UPDATE TCRD SET NDOSS = '1/' || CAST(MS7.substring(CAST(year(CURRENT TIMESTAMP) AS VARCHAR(30)), 3, 2) AS VARCHAR(...
  3. Microsoft SQL DMO(ODBC: SQLstate 42000) error
    Hi, While restoring the SQL serverdatabase, I obtain the following error: Microsoft SQL DMO(ODBC: SQLstate 42000): The backup of the system database on devise XXXX cannot be restored because it was created by a different version of the server (117441211) than this server (...
  4. SQLSTATE: 22003
    when i am trying to crate nick name (using federated system creating nickname from as400 (os/400) to iDB2/NT 8.2.1f advise its urgent SQLSTATE: 22003 Explanation: The numeric value received from the AS was out of the supported range. System Action: The host variable was no...
  5. How to resolve the error: Microsoft SQL DMO (ODBC SQ…
    Do you know how I can resolve the error in the stored procedure that follows: Microsoft SQL DMO (ODBC SQLSTATE 42S22) Error 207 Invalid column name 'CustomerNumber' Invalid column name 'OfficeNumber' I am able to narrow the error down to the following ON statement: ON ...
  6. Microsoft SQL-DMO (ODBC SQLState: 42S22)
    I wanted to change to data type of ProductID to nvarchar in my stored procedure but I get the following error. (I changed the data type of ProductID from int to nvarchar in my database.) Microsoft SQL-DMO (ODBC SQLState: 42S22) Error 207: Invalid column name 'ProductID'. I...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: gajender_99Posted on 2005-05-25 at 04:20:17ID: 14076153

i think the variable you are passing  is of date type where the argument in the datawindow is datetime or vis versa check your setting

or post the script where you are retrieving the data for the data window
gajender

 

by: kathotiaPosted on 2005-05-25 at 08:59:06ID: 14078731

the procedure uses a datetime variable to receive the argument and the datawindow retrieve function also passes a datetime variable.

Earlier I used PB 6.5 with MSS conntivity to SQL server but with PB 10.2 native connectivity is not available, I am using OLEDB to connect and this ODBC related problem has crept up.

 

by: gajender_99Posted on 2005-05-26 at 00:52:21ID: 14083875

POST YOUR SQL AND THE SCRIPT

 

by: kathotiaPosted on 2005-05-26 at 02:41:44ID: 14084331

The following is the stored procedure

CREATE PROCEDURE sp_checksyntax(@ldm datetime) AS
BEGIN
SELECT sdm = @ldm
END


Powerbuilder is not allowing me to even create a datawindow using the above stored procedure. I just gives out the error code as stated above.

This problem is definetly with ODBC drivers.

 

by: kathotiaPosted on 2005-05-26 at 02:45:59ID: 14084348

The problem is not specific to datetime variable, I changed the variable to varchar still the same problem
However, if i excute the sp from ISQL the procedure works .

 

by: BenClarkPosted on 2005-05-26 at 08:03:13ID: 14086633

I think all you need to do is turn off 'Use Call Escape Syntax' in your database profile.

 

by: kathotiaPosted on 2005-05-28 at 08:36:27ID: 14101777

i have tried all permutation in database profiles. Still the same problem. Even though data window creation is now possible but retreiveal through power script --- dw_1.retrieve(ldt_ldm) is still giving the same error.

 

by: kathotiaPosted on 2005-05-31 at 01:52:01ID: 14111492

I have tried connecting to SQL server through  ODBC, OLEDB, ADO .NET but at all times the same erro props up and the data retreival fails

Please help

 

by: gajender_99Posted on 2005-05-31 at 05:40:38ID: 14112626

I believe the following may solve your problem:

In development mode, on the "Connection" tab of the database profile, enter the following string for the "Driver-Specific Parameters"

DelimitIdentifier='No',MsgTerse='Yes',CallEscape='No',FormatArgsAsExp='N'

I hope this helps. Let me know if this solves your problem

 

by: diasroshanPosted on 2005-05-31 at 22:21:12ID: 14119021

Hi,

can u post ur connectstring...


here is an example...
SQLCA.DBParm = "ConnectString='DSN=PC-CMS;UID=sa;PWD=;',StripParmNames = 'Yes'"

so what u need to add is  --->  ,StripParmNames = 'Yes'

this will sort ur problem...

Let me know if u need more assistance...

Cheers,
Rosh

 

by: kathotiaPosted on 2005-06-01 at 08:51:32ID: 14122917

when using ADO.net 'stripparmnames' is not supported

 

by: kathotiaPosted on 2005-06-20 at 04:50:19ID: 14255834

moderators please split the points to all persons who gave a response and close the topic.

I found out the reason for the problem but notthe solution.

The problem is specifically with ODBC and is not there with OLEDB or ADO.NET. Actuallythe template generated by PB102 uses ODBC by force througha NVO. which resulted in the error.

He problem got solved by using ADO.NET and connecting to the database usning powerscrip after disabling th NVO.

 

by: BenClarkPosted on 2005-06-20 at 05:19:55ID: 14255984

Kathotia,
I went back through some of my code. I have run into this before.
The problem is the DateTime column.
PowerBuilder uses its PBODB??.INI file to keep information about each of the database types
using ODBC. If the settings in the PBODB??.INI has the Datetime formatting set to a format
that is incompatible with the database format, you will run into this error.
If you use embedded SQL in a script, you can see how this works.
Example:
SELECT ??
INTO :var
FROM tbl
WHERE col = :dtData
Reguardless of the dtData formatting, when PowerBuilder passes it to the database, the
datetime formatting will be changed to match the formatting in the PBODB??.INI file.
Changing the dtData to a StrData will have no effect.
An automattic type conversion will still convert the data into a datetime.
You can test this by changing the formatting of the datetime data being passed.
Example:
SELECT ??
INTO :var
FROM tbl
WHERE col = :var2  

var2 = String(dtData, 'mm/dd/yyyy hh:mm:ss')
  OR
var2 = String(dtData, 'yyyy/mm/dd hh:mm:ss')
  OR
var2 = String(dtData, 'yy/mm/dd hh:mm:ss')
etc...

I had alot of trouble with this in PB 7 but not any any other version.
Your simptoms appear to be axactly the same.
Also, check the 'Syntax' tab of your profile. You will see
entries for 'Date Format', 'DateTime Format', etc..
Typically they are empty. If you have something there, remove it.
If yours are empty, fill them in.

Ben

 

by: kathotiaPosted on 2005-06-20 at 06:06:04ID: 14256291

I was facing this problem not with datetime type variable but will all type of paramters so it is logically assumend the problem lies with ODBC drivers.

SYBASE site has solutions to this problem but it is locked and is avaiable to only PAID SUPPORT SUBSCRIBERS.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...