Hi,
Please i want my application to display the autogenerated ID in a messagebox after an insert has taken place and this autogenertaed id is a GUID form.
Please help, i have tried @@identity and select_identity() but it wont display any value.
Heres how my code is from d insert section
command.CommandText = "INSERT INTO dbo.Clients (FirstName, LastName, Organisation, Address, Purpose, PhoneNo, Time ) VALUES (@fnames, @lnames, @organisatn, @addres, @purposes, @phone, @tim );"+"SELECT @@IDENTITY";
command.Parameters.Add("@fnames", SqlDbType.VarChar).Value = Fname.Text;
command.Parameters.Add("@lnames", SqlDbType.VarChar).Value = Lname.Text;
command.Parameters.Add("@organisatn", SqlDbType.VarChar).Value = org.Text;
command.Parameters.Add("@addres", SqlDbType.VarChar).Value = addy.Text;
command.Parameters.Add("@purposes", SqlDbType.VarChar).Value = purpos.Text;
command.Parameters.Add("@phone", SqlDbType.Int).Value = fone.Text;
command.Parameters.Add("@tim", SqlDbType.DateTime).Value = tims.Value;
object oo = command.ExecuteScalar();
MessageBox.Show(string.Format("Your Reference code is "+oo), "PIN", MessageBoxButtons.OK, MessageBoxIcon.Information);