Link to home
Start Free TrialLog in
Avatar of kwh3856
kwh3856Flag for United States of America

asked on

Cannot implicitly convert type 'string' to 'char?

I know this is simple for most of you out there but I do not know the coversion syntax it needs.  Can someone post up the syntax for this conversion.

myCRpatient.SEX = patient.u.sex;------Squiggly line under patient.u.sex

Open in new window

Avatar of rowansmith
rowansmith

It depends completely on what the types are defined as?

Is myCRpatuient.SEX a string? a Boolean?  a number? what is it?

And then what type is patient.u.sex ?

To set them you have to know what each one is, if you mouse over them the IDE will let you know what they are.

-Rowan

Avatar of kwh3856

ASKER

myCRpatient.Sex is a VARCHAR(1) in the database
patient.u.sex is a nvarchar
 
ASKER CERTIFIED SOLUTION
Avatar of Tony McCreath
Tony McCreath
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You should do one of the following

Change the type of patient.u.sex to a string

or you might be able to use

patient.u.sex.tostring

to convert the char to a string
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kwh3856

ASKER

Cholor's Dad,
I tried that and it did not work.  I tried tiggerito and it worked the first time.  

DropZone,
Thank you.  I am now using your logic in many different places in my code.  Thank you for turning on the lights and bringing clairity to my understanding of conversions.
No worries.  I always think it is better to explain the root cause of a problem and showing how to avoid it than to just give a code solution.  "Give a man a fish...", and all that.

    Cheers!
     -dZ.