I'm testing a table and .net form and am trying to change from using a UNIQUEIDENTIFIER to Int.
On the table, I removed the UNIQUEIDENTIFIER, and created a new column with the same name but with data type Int.
On my code behind I've changed the insert to reference the Int data type, except I don't know how to change this reference so that it creates a new Int rather than GUID?
"Guid RegistrationID = Guid.NewGuid();"
protected void Button1_Click(object sender, EventArgs e)
// generate new RegistrationID
Guid RegistrationID = Guid.NewGuid();
// create insert query
using (SqlCommand command = new SqlCommand())
command.Connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString);
command.CommandText = @"insert into [Registration](RegistrationID, FirstName, LastName)
values(@RegistrationID, @FirstName, @LastName)";
command.Parameters.Add("@RegistrationID", SqlDbType.Int).Value = RegistrationID2;
command.Parameters.Add("@FirstName", SqlDbType.VarChar, 128).Value = litFirstName.Text;
command.Parameters.Add("@LastName", SqlDbType.VarChar, 128).Value = litLastName.Text;
I get this error when trying the above code:
Object must implement IConvertible.
Thanks for the help.