public void CreateFiles(Files files) { DbCommand command = SqlConncetionHelper.Connection.CreateCommand(); DbParameter formatParametr = command.CreateParameter(); formatParametr.DbType = System.Data.DbType.String; formatParametr.IsNullable = false; formatParametr.ParameterName = "@Format"; formatParametr.Value = files.Format; DbParameter nameParametr = command.CreateParameter(); nameParametr.DbType = System.Data.DbType.String; nameParametr.IsNullable = false; nameParametr.ParameterName = "@Name"; nameParametr.Value = files.Name; DbParameter wayParametr = command.CreateParameter(); wayParametr.DbType = System.Data.DbType.String; wayParametr.IsNullable = false; wayParametr.ParameterName = "@Way"; wayParametr.Value = files.Way; DbParameter userIdParametr = command.CreateParameter(); userIdParametr.DbType = System.Data.DbType.Int32; userIdParametr.IsNullable = false; userIdParametr.ParameterName = "@userId "; userIdParametr.Value = files.UserId; command.Parameters.AddRange(new DbParameter[] { formatParametr, nameParametr, wayParametr }); command.CommandText = @"INSERT INTO [dbo].[Files] ([format ],[Name],[Way],[user_id]) VALUES (@Format,@Name,@Way,@userId)"; SqlConncetionHelper.ExecuteCommands(command); }
public void CreateUsers(Users user) { DbCommand command = SqlConncetionHelper.Connection.CreateCommand(); DbParameter nicknameParametr = command.CreateParameter(); nicknameParametr.DbType = System.Data.DbType.String; nicknameParametr.IsNullable = false; nicknameParametr.ParameterName = "@Nickname"; nicknameParametr.Value = user.Nickname; DbParameter passwordParametr = command.CreateParameter(); passwordParametr.DbType = System.Data.DbType.String; passwordParametr.IsNullable = false; passwordParametr.ParameterName = "@password"; passwordParametr.Value = user.Password; command.Parameters.AddRange(new DbParameter[] { nicknameParametr, passwordParametr }); command.CommandText = @"INSERT INTO [dbo].[users] ([nickname],[password]) VALUES (@Nickname, @password)"; SqlConncetionHelper.ExecuteCommands(command); }