Showing posts with label character. Show all posts
Showing posts with label character. Show all posts

Sunday, February 19, 2012

"Invalid Character value for cast specification" from VC++ when i execute a proc

Hi Everybody,

I have a question regarding the running of a procedure from VC++ in SQL server.

well this is the scenario.

i have a procedure in SQL server and i am running that thru my VC++ code.
:eek:
i have a recordset class and i create an object of it and then do a obj.Open(). the procedure is fetching 24 records correctly in the query analyser and in my while(!(obj.IsEOF())) loop it gets the first record correctly but the moment it encounters obj.MoveNext(); it bombs and gives me the following error..

"Invalid Character value for cast specification ".

i don't know why this is happening

Thanks for you help.Somewhere in your Transact-SQL code you are trying to convert a character value to another datatype. My first guess would be DATETIME, next might be INT or another numeric datatype. This is usually either in a column you are returning or in a WHERE clause, but it can happen anywhere you can refer to a column.

-PatP|||BTW, since this actually appears to be a Transact-SQL problem, I'm moving the thread back to the Microsoft SQL forum.

-PatP

"Invalid character in the given encoding". XML bulk load, SQLE

Hi Martin,
I confirm that the problem is the presence of the character "è", even if it
is in the comment. How can I solve the problem?
I have put the line
<?xml version="1.0" encoding="utf-8"?>
for the encoding. What else should I do?
"Martin Honnen" wrote:

> Tatopitta wrote:
>
> The error usually means that a byte sequence has been encountered that
> does not map to a character in the specified encoding in the XML
> declaration.
> --
> Martin Honnen -- MVP XML
> http://JavaScript.FAQTs.com/
>Tatopitta wrote:

> I confirm that the problem is the presence of the character "è", even if
it
> is in the comment. How can I solve the problem?
> I have put the line
> <?xml version="1.0" encoding="utf-8"?>
> for the encoding. What else should I do?
Make sure the document is really UTF-8 encoded, with UTF-8 the character
"è" needs to be encoded with the two byte sequence C3 A8.
Martin Honnen -- MVP XML
http://JavaScript.FAQTs.com/

Saturday, February 11, 2012

"Conversion failed when converting from a character string to uniqueidentifier."

This is probably a simple wuestion but i would appreciate some help

I am trying to get and insert theuserId into a table called "Orders"

I got the user id as

Dim CustomerId As Object = Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString

The button on click command is

worldshop.ShoppingCart.CreateOrder(CustomerId,...................

The Function Has the parameter for Customer Id as follows

Dim dbParam_CustomerId As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_CustomerId.ParameterName = "@.CustomerId"
dbParam_CustomerId.Value = CustomerId
dbParam_CustomerId.DbType = System.Data.DbType.String
command.Parameters.Add(dbParam_CustomerId)

When i run this I am getting the error message

"Conversion failed when converting from a character string to uniqueidentifier."

Can anyone tell me where I am going wrong


many thanks

Martin

What type is CustomerID defined as in the database? It sounds like it is NOT a string, but rather a uniqueidentifier (a GUID).|||

thanks for your reply. i got it sorted out

martin

|||Do you mind sharing with us what your solution was? as I am having the same problem...|||

I'll check and get back to you

martin

|||

sorry about the delay in getting back to you

I was having the same problem. I solved it by instantiating the userid as an object

Dim userId As Object = Membership.GetUser(User.Identity.Name).ProviderUserKey

i passed the object to the function as a guid

ByVal userId As Guid
Dim dbParam_userId As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_userId.ParameterName = "@.UserId"
dbParam_userId.Value = userId
dbParam_userId.DbType = System.Data.DbType.Guid
command.Parameters.Add(dbParam_userId)

last i put the guid into the database as char 36

@.UserId char (36)

HTH

Friday, January 27, 2012

doesn't work in LIKE wildcards?

I have table of stocks that includes a varchar field that can optionally hold
a formula. You can identify formulas because the first character is "=". You
can also include the names of other stocks in the formula by surrounding the
ticker in !'s. For instance:
=!MSFT! * 2
I need to find all the formulas that do contain a ticker in them, so that I
can look up the stocks they refer to.
The obvious solution is ... WHERE formula LIKE '=%!'. The obvious solution
does not work. Removing the ! returns all the formulas. Anyone know what
would cause this? ! does not appear in the docs as a reserved word or
wildcard.
MauryHello Maury,
> I have table of stocks that includes a varchar field that can
> optionally hold a formula. You can identify formulas because the first
> character is "=". You can also include the names of other stocks in
> the formula by surrounding the ticker in !'s. For instance:
> =!MSFT! * 2
> I need to find all the formulas that do contain a ticker in them, so
> that I can look up the stocks they refer to.
> The obvious solution is ... WHERE formula LIKE '=%!'. The obvious
> solution does not work. Removing the ! returns all the formulas.
> Anyone know what would cause this? ! does not appear in the docs as a
> reserved word or wildcard.
> Maury
>
I think it's the fact that you didn't add a trailing %
where formula like %!%
Jesse Houwing
jesse.houwing at sogeti.n|||Ohh geez, nevermind!