We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Operator '=' is not defined for types 'System.Object' and 'System.Guid'.

David_Reid_1985
on
Medium Priority
387 Views
Last Modified: 2008-01-09
Can anyone advise how I should be doing this in vb.Net 2003?

The line of code I'm trying to run is:

   SQLCommand.Parameters.Add(New VistaDB.VistaDBParameter("@ID", VistaDB.VistaDBType.Guid).Value = myGuid)

myGuis is of type System.GUID whereas the parameter wants an object? I thought this would be ok?

Please help!!
Comment
Watch Question

Commented:
You need to convert myGuid to String

e.g.  SQLCommand.Parameters.Add(New VistaDB.VistaDBParameter("@ID", VistaDB.VistaDBType.Guid).Value = myGuid.ToString())

Author

Commented:
Apologies, I should have mentioned, already tried that... I now receive:

"Specified cast is not valid."

:(

Any ideas?

Commented:
You could try

SQLCommand.Parameters.Add(New VistaDB.VistaDBParameter("@ID", VistaDB.VistaDBType.Guid, myGuid.ToString())

Commented:
Forget a bracket

SQLCommand.Parameters.Add(New VistaDB.VistaDBParameter("@ID", VistaDB.VistaDBType.Guid, myGuid.ToString()))
I'm close to telling you just to do it on two lines :-), but:
What if you try
SQLCommand.Parameters.Add(New VistaDB.VistaDBParameter("@ID", VistaDB.VistaDBType.Guid).Value = ctype(myGuid,object))

Senior Systems and Integration Developer
CERTIFIED EXPERT
Commented:
The location of your brackets is causing the problem:

    SQLCommand.Parameters.Add(New VistaDB.VistaDBParameter("@ID", VistaDB.VistaDBType.Guid)).Value = myGuid

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Gawwd its been one of those days!!! Thanks very much :D:D:D:D
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.