Link to home
Start Free TrialLog in
Avatar of siva_iaf
siva_iaf

asked on

GUID

hi im trying to do this:
  Dim MyGuid As Guid = New Guid("4FD19834JLKJF-FSKFF")
    Dim Author As AuthBl = New AuthBl(MyGuid)

here i couldnt pass the value of MyGuid...it alwyas shows its empty.
how to pass the exact value to myGuid .this myGUid is passed as a parameter to the stored procedure  to retrieve the particular record from the table.


Avatar of Kumaraswamy R
Kumaraswamy R
Flag of India image

Dim MyGuid as Guid = Guid.NewGuid()
  Dim Author As AuthBl = New AuthBl(MyGuid)
Avatar of siva_iaf
siva_iaf

ASKER

It shows me the foll error :

structure"system.Guid" cannot be indexed because it has no default property

in the line Guid.NewGuid()
ok, if you are trying to view the Guid value in the quickwatch you wont see it not sure why. problem with the ide?? try this you will see s has a value of the guid

Dim MyGuid As Guid = Guid.NewGuid()
 Dim s As String = MyGuid.ToString()
s += ""
and if you need to pass the actual value just use
MyGuid.ToString()
Dim MyGuid as Guid = Guid.NewGuid()
  Dim Author As AuthBl = New AuthBl(MyGuid.tostring())
use the namespace

System.InteropServices
Hello burakiewicz

Dim MyGuid As Guid = New Guid("4FD19834JLKJF-FSKFF")
    I want the assign the Guidvalue("4FD19834JLKJF-FSKFF") to myGuid .
Dim Author As AuthBl = New AuthBl(MyGuid as Guid)

here i cannot pass the parameter(MyGuid) as string.
you can pass it as a guid, but when you setup the parameter for the stored proc try it with the Guid.ToString()
The code you have should work perfectly fine, unless that's the actual value you're passing.
"4FD19834JLKJF-FSKFF" is not a valid ID, and will fail in the call to new Guid("....").

Since GUID is a value type, it always has a value, and will initialize to Guid.Empty.

Guid's must be 32 characters long, ie:
31B53463-4B4D-4C75-8EDE-6521AA2C9F5A
20C15BFE-72AA-4040-B4F9-DE4D7CFB0840
And you should only convert it to a string when passing to the sp if the sp is actually expecting a varchar / nvarchar value.

But you should have it setup to expect a uniqueidentifier paramter, in which case you would pass the guid exactly as it is.
you dont have on error resume next anywhere do you?
hello snarf

I just gave the GUID value for an example.i know it is 32 character long  and also the parameter expects a uniqueidentifier.I can pass it as a string and get it woking but i want to pass the value as GUID.
Okay, so in the stored proc, what type is the parameter expecting?  is it varchar / nvarchar or uniqueidentifier?
uniqueidentifier
Can you post the .net code where you're calling the proc?
I dont think that will help me

Dim MyGuid As Guid = New Guid("31B53463-4B4D-4C75-8EDE-6521AA2C9F5A")
   I just wanted to know how to assign this value 31B53463-4B4D-4C75-8EDE-6521AA2C9F5A to MyGuid.The above code assigns empty value to MyGuid.
ASKER CERTIFIED SOLUTION
Avatar of Snarf0001
Snarf0001
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
yeah thats the problem with the ide i mentioned.  everthing you had should be working right, but it just wont look right in the debugger
i got the result only after lot of comments