Solved

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

Posted on 2006-10-26
7
344 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
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…

803 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