Option Strict On disallows implicit conversions from 'Object' to 'System.Guid'

Posted on 2008-11-07
Last Modified: 2012-05-05
I'm getting the following error:

Option Strict On disallows implicit conversions from 'Object' to 'System.Guid'

Here's my code:

Dim prmOutputParam As SqlParameter = cm.Parameters.Add("@UserKeyGUID", SqlDbType.UniqueIdentifier)
prmOutputParam.Direction = ParameterDirection.Output

Dim tmpGUID As Guid
tmpGUID = cm.Parameters("@UserKeyGUID").Value

What is the proper way to tell .NET that cm.Parameters("@UserKeyGUID").Value is a Guid and not an Object?

Question by:CarlaGibson
    LVL 62

    Accepted Solution

    This should work.

    tmpGUID = CType(cm.Parameters("@UserKeyGUID").Value, Guid)

    Author Comment

    Perfect!  I knew it was something easy!!  Thanks!

    Author Closing Comment

    LVL 62

    Expert Comment

    by:Fernando Soto
    Not a problem, glad I was able to help.  ;=)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    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.

    Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    759 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

    13 Experts available now in Live!

    Get 1:1 Help Now