Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Passing GUID as parameter to an Insert Query - invalid conversion to string

$
0
0
I've got a view in SQL Server that has an Instead of Trigger. The view consists of two tables with a GUID as common Primary Key. This particular GUID is named "vHoleGridpkDrillHole"

The data designer will not create an Update or Insert Query - so I've had to create my own in the designer.

I'm trying to pass the GUID in the Insert query, and get the error, "Invalid cast from 'System.String' to 'System.Guid'." when I run the program and click on the "Insert" button.

My syntax for passing the parameter is:

(System.Guid)(System.Convert.ChangeType ( vHoleGridDataGridView.CurrentRow.Cells["vHoleGridpkDrillHole"].Value.ToString (), typeof ( System.Guid ) )),

I've also tried: vHoleGridDataGridView.CurrentRow.Cells["vHoleGridpkDrillHole"].Value.ToString(), and other variants to no avail.

What is the cast that will work?

I know there is a bug in the "Preview Data" feature that prevents you from entering a GUID string - is this the same bug?

Thanks
S



Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>