My SQL database (RatingDbSQL) has 3 tables and the 'Persons' table comprises:
Column(0) as Unique ID;
Column(1) FirstName as String; Column(2) LastName as String.
The database Provider is: .NET Framework Data Provider for SQL Server
The data loads from the Database OK using:
ConRatingDB.Open()
Me.PersonsTableAdapter.Fill(Me.DsRatingDbSQL.Persons)
daPersons.Fill(DsRatingDbSQL, "Persons")
ConRatingDB.Close()
The other two tables are non starters until I resolve saving data to the Persons Table using the following:
- - - - - - - - - - -
The first line (Update) returns with:
System.InvalidCastException – Failed to convert parameter value from a Int32 to a Guid
daPersons.Update(DsRatingDbSQL.Tables("Persons"))
DsRatingDbSQL.Tables("Persons").Clear()
daPersons.Fill(DsRatingDbSQL, "Persons")
The Properties of the ID column are:
DataType: UniqueIdentifier
Length: 16
Nullable: False
- - - - - - - - - - -
I have read many Internet articles on similar problems but don’t understand how to implement them:
The following three look interesting – but I’m lost on how to implement:
Guid guid = new Guid(sqlCmd.Parameters["@UserID"].Value.ToString())
Or:
Dim ID as String = commandArgs(0).ToString()
Dim FirstName as String = commandArgs(1).ToString()
Dim LastName as String = commandArgs(2).ToString()
Or:Dim i as Integer
Public Overridable Function GetGuid(ByVal i As Integer) As Guid Implements IDataRecord.GetGuid
Could anyone advise please