I have a field called NewID in a table that is of type UniqueIdentifier. I then create my data layer which consists of a tableAdapter that contains a query (sql statement):
NewID is of UniqueIdentifier in SQL Server 2005 and it maps to "Guid" in ADO.Net. I guess parameter @NewID is of string type so make it of type System.Guid.
This is what confuses me :(. In the database the field is set to UI (UniqueIdentifier). When i create my tableadapter and add my query i create the above query but unsure where its tagged as String.
When i create my tableadapter and add my query i create the above query but unsure where its tagged as String.
If you can't figure it out yourself....paste your code here or try to find where are you setting the datatype of @NewID
Ive not written any code so far except for the SQL code. Ill write the steps ive taken.
1. Database - Created a table then a field and setting the type with UniqueIdentifier.
2. In Visual Studio - Add dataset, right click inside the dataset and select the tableadapter option > Use SQL statements > Select all the columns.
3. Did step 2 again except this time i added a WHERE clause (where NewID=@NewID)
4. Right click the query i created in step 3 and click Preview Data. Enter an existing GUID from another table (copy and paste) and then pass it as a parameter. This is when i get the error above.
Heres the strange part. If i go into the query and then go into Query Builder, i can enter the GUID into the window that opens (called Query Parameters). Once i enter the GUID and click execute the query runs fine within that window.
EssCee
Member
548 Points
761 Posts
Failed to convert parameter value from string to guid
Oct 10, 2012 08:39 AM|LINK
I have a field called NewID in a table that is of type UniqueIdentifier. I then create my data layer which consists of a tableAdapter that contains a query (sql statement):
select col1, col2, from table where NewID=@NewID
When i try and preview the results i get the error "Failed to convert parameter value from string to guid".
Im not sure how to resolve this?
Thanks
kaushikmahet...
Contributor
3750 Points
887 Posts
Re: Failed to convert parameter value from string to guid
Oct 10, 2012 09:49 AM|LINK
which datatype ur column..pls tell me
Remember to click Mark as Answer on the post that helps to others.
EssCee
Member
548 Points
761 Posts
Re: Failed to convert parameter value from string to guid
Oct 10, 2012 09:51 AM|LINK
If ive understood you correctly the data type of the column in the database is a UniqueIdentifier
me_ritz
Star
9337 Points
1447 Posts
Re: Failed to convert parameter value from string to guid
Oct 10, 2012 10:13 AM|LINK
NewID is of UniqueIdentifier in SQL Server 2005 and it maps to "Guid" in ADO.Net. I guess parameter @NewID is of string type so make it of type System.Guid.
Refer to the link:
http://msdn.microsoft.com/en-us/library/vstudio/cc716729(v=vs.100).aspx
EssCee
Member
548 Points
761 Posts
Re: Failed to convert parameter value from string to guid
Oct 10, 2012 10:28 AM|LINK
This is what confuses me :(. In the database the field is set to UI (UniqueIdentifier). When i create my tableadapter and add my query i create the above query but unsure where its tagged as String.
me_ritz
Star
9337 Points
1447 Posts
Re: Failed to convert parameter value from string to guid
Oct 10, 2012 11:12 AM|LINK
If you can't figure it out yourself....paste your code here or try to find where are you setting the datatype of @NewID
EssCee
Member
548 Points
761 Posts
Re: Failed to convert parameter value from string to guid
Oct 10, 2012 11:24 AM|LINK
Ive not written any code so far except for the SQL code. Ill write the steps ive taken.
1. Database - Created a table then a field and setting the type with UniqueIdentifier.
2. In Visual Studio - Add dataset, right click inside the dataset and select the tableadapter option > Use SQL statements > Select all the columns.
3. Did step 2 again except this time i added a WHERE clause (where NewID=@NewID)
4. Right click the query i created in step 3 and click Preview Data. Enter an existing GUID from another table (copy and paste) and then pass it as a parameter. This is when i get the error above.
Thanks
EssCee
Member
548 Points
761 Posts
Re: Failed to convert parameter value from string to guid
Oct 10, 2012 11:42 AM|LINK
Heres the strange part. If i go into the query and then go into Query Builder, i can enter the GUID into the window that opens (called Query Parameters). Once i enter the GUID and click execute the query runs fine within that window.
Cathy Mi - M...
Member
741 Points
165 Posts
Microsoft
Re: Failed to convert parameter value from string to guid
Oct 23, 2012 03:39 PM|LINK
Hi,
What version of Visual Studio are you using?
Thanks,
Cathy Miller