public void Add() { using (SqlCmd cmd = new SqlCmd("INSERT INTO ContentPage VALUES (@Name, @Path, @Content) SET @Id = SCOPE_IDENTITY()", false)) { cmd.AddIString("@Name", 100, Name); cmd.AddIString("@Path", 100, Path); cmd.AddIString("@Content", -1, Content); cmd.AddOInt("@Id"); cmd.Execute(); Id = cmd.GetInt("@Id"); } }
public void Add(string password, string ip, Guid emailConfirmation) { using (SqlCmd cmd = new SqlCmd("INSERT INTO [User] (UserName, UserEmail, UserPassword, TimeZone, IPAddress, IsActive, EmailConfirmation) VALUES (@UserName, @UserEmail, @Password, @TimeZone, @IPAddress, 0, @EmailConfirmation); SET @Id = SCOPE_IDENTITY();", false)) { cmd.AddIString("@UserName", 40, UserName); cmd.AddIString("@UserEmail", 50, Email); cmd.AddIString("@Password", 250, password); cmd.AddIString("@TimeZone", 50, TimeZone.Id); cmd.AddIString("@IPAddress", 100, ip); cmd.AddIGuid("@EmailConfirmation", emailConfirmation); cmd.AddOInt("@Id"); cmd.Execute(); Id = cmd.GetInt("@Id"); } }
public void Add() { using (SqlCmd cmd = new SqlCmd("INSERT INTO Article VALUES (@UserId, @Title, @SubHeading, @ShortDescription, @Content, @PublishDate, @UrlLabel); SET @Id = SCOPE_IDENTITY();", false)) { cmd.AddIInt("@UserId", Author.Id); cmd.AddIString("@Title", 300, Title); cmd.AddIString("@SubHeading", 300, SubHeading); cmd.AddIString("@ShortDescription", 1000, ShortDescription); cmd.AddIString("@Content", -1, Content); cmd.AddIDateTime("@PublishDate", PublishDate); cmd.AddIString("@UrlLabel", 300, CreateUrl()); cmd.AddOInt("@Id"); cmd.Execute(); Id = cmd.GetInt("@Id"); } }