?
Solved

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

Posted on 2006-10-26
7
Medium Priority
?
348 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
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 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
Progress
Starting up a Project
Suggested Courses

771 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