dshi15
asked on
How to use Guid datatype in C#
Hi Expert,
I like to insert data to a column which are Guid datatype.
I like to insert two records
@p_Student_ID = new Guid("1A1A1A1A-AD43-499E-8 39F-32E31A 1A1A1A")
@p_Student_ID = new Guid("1B1B1B1B-AD43-499E-8 39F-32E31B 1B1B1B")
Can I declare a variable and assign a value later like string?
String S1="";
If (i==0)
S1='Test1;
Else if (i==1)
S1='Test2;
Thanks in advance
I like to insert data to a column which are Guid datatype.
I like to insert two records
@p_Student_ID = new Guid("1A1A1A1A-AD43-499E-8
@p_Student_ID = new Guid("1B1B1B1B-AD43-499E-8
Can I declare a variable and assign a value later like string?
String S1="";
If (i==0)
S1='Test1;
Else if (i==1)
S1='Test2;
Thanks in advance
ASKER
It is class member, but how I can declare it and assign value in the method,
Public Class ABC
{
Guid Student_ID =New Guid("");
Public void DEF()
{
for (int i = 0; i <= 1; i++)
{
If (i==0)
Student_ID =new Guid("1A1A1A1A-AD43-499E-8 39F-32E31A 1A1A1A")
Else if (i==1)
Student_ID =new Guid("1B1B1B1B-AD43-499E-8 39F-32E31B 1B1B1B")
other code here
cmd.Parameters.AddWithValu e("@p_Stud ent_ID", Student_ID);
the syntax isn't correct, what is correct syntax to declare this Guid variable and assign these value to it?
Thanks,
Public Class ABC
{
Guid Student_ID =New Guid("");
Public void DEF()
{
for (int i = 0; i <= 1; i++)
{
If (i==0)
Student_ID =new Guid("1A1A1A1A-AD43-499E-8
Else if (i==1)
Student_ID =new Guid("1B1B1B1B-AD43-499E-8
other code here
cmd.Parameters.AddWithValu
the syntax isn't correct, what is correct syntax to declare this Guid variable and assign these value to it?
Thanks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you can generally assign values at any given time but you cannot access before a value is assigned...
im not sure if i have understood your question so if you need more information, just let me know