[Homework] Data Definition and Data Types - Problem 7
Здравейте колеги,
моля за малко помощ.
Не мога да разбера къде бъркам. В Джъдж-а ми дава компилационна грешка:
ExecuteNonQuery: CommandText property has not been initialized
Ето кода ми:
CREATE TABLE Users
(
Id INT UNIQUE IDENTITY(1,1),
Name NVARCHAR(200) NOT NULL,
Picture VARBINARY(max),
Height FLOAT(2),
Weight FLOAT(2),
Gender NVARCHAR(1) NOT NULL,
Birthdate DATE NOT NULL,
Biography NVARCHAR(max)
)
ALTER TABLE Users
ADD PRIMARY KEY (Id)
INSERT INTO Users(Name, Picture, Height, Weight, Gender, Birthdate, Biography) VALUES ('Pesho', NULL, 1.78, 56.6, 'm', '1982-01-12', 'this is the bio')
INSERT INTO Users(Name, Picture, Height, Weight, Gender, Birthdate, Biography) VALUES ('Rosko', NULL, 1.88, 78.6, 'm', '1985-11-12', 'this is the bio')
INSERT INTO Users(Name, Picture, Height, Weight, Gender, Birthdate, Biography) VALUES ('Goshko', NULL, 1.78, 56.6, 'm', '1982-01-23', 'this is the bio')
INSERT INTO Users(Name, Picture, Height, Weight, Gender, Birthdate, Biography) VALUES ('Mina', NULL, 1.68, 55.6, 'f', '1987-12-01', 'this is the bio')
INSERT INTO Users(Name, Picture, Height, Weight, Gender, Birthdate, Biography) VALUES ('Deni', NULL, 1.78, 57.6, 'f', '1983-01-18', 'this is the bio')
Благодаря колега, смених името, махнах и UNIQUE полето и ми го прие :)
На колоната Gender е хубаво да се постави ограничение в знака(да е или m или f).
Нещо такова
gender varchar(1) NOT NULL CHECK(gender in('f','m'))