I am trying to pass a series GUIDs to a Stored Procedure and am getting this error:
Failed to convert parameter value from a Guid to a String (focus goes to the ExecuteNonQuery.
VB Code:
' Private Sub SelectRecordstoDelete() Dim cnn As New SqlConnection(aCon) Dim cmd As New SqlCommand Dim da As New SqlDataAdapter Dim ds As New DataSet cmd = cnn.CreateCommand cmd.CommandText = "Select FormID From " & _ "tbl_Forms Where DateSubmitted Between " & _ "'2007-02-02' and '2007-02-06'" da.SelectCommand = cmd da.Fill(ds, "IDs") With ds.Tables("IDs") For i As Integer = 0 To .Rows.Count - 1 DeleteRecords(.Rows(i).Item(0)) Next End With End Sub Sub DeleteRecords(ByVal myGUID As Guid) Dim da As New SqlDataAdapter Dim ds As New DataSet Dim strSp As String = "spd_DeleteForm" Dim cn As SqlConnection = New SqlConnection(aCon) Dim cmd As SqlCommand = New SqlCommand(strSp, cn) cn.Open() With cmd .CommandType = CommandType.StoredProcedure .Parameters.Add( _ "@FormID", _ SqlDbType.VarChar, 50).Direction = _ ParameterDirection.Input .Parameters("@FormID").Value = myGUID .ExecuteNonQuery() End With End Sub




Reply With Quote