Solved

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

Posted on 2006-10-26
7
338 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!!
0
Comment
Question by:David_Reid_1985
7 Comments
 
LVL 4

Expert Comment

by:hclgroup
ID: 17813080
You need to convert myGuid to String

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

Author Comment

by:David_Reid_1985
ID: 17813188
Apologies, I should have mentioned, already tried that... I now receive:

"Specified cast is not valid."

:(

Any ideas?
0
 
LVL 4

Expert Comment

by:hclgroup
ID: 17813252
You could try

SQLCommand.Parameters.Add(New VistaDB.VistaDBParameter("@ID", VistaDB.VistaDBType.Guid, myGuid.ToString())
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 4

Expert Comment

by:hclgroup
ID: 17813254
Forget a bracket

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

Expert Comment

by:davbouchard
ID: 17813283
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))

0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 17813367
The location of your brackets is causing the problem:

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

Author Comment

by:David_Reid_1985
ID: 17814314
Gawwd its been one of those days!!! Thanks very much :D:D:D:D
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Order table with macro 3 75
Excel object stays open 19 65
triangle challenge 4 77
Exe program is not a valid Win 32 application 15 95
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now