Reputation: 13248
I would like to know is there a way to insert values to the same column without updating the same value.
This is my table structure
Column Name Data Type Allow Nulls
----------- --------- ------------
Expiry Date Date No
Now I would like to insert multiple date values in the Expiry Date. So how do I do that?
So that my output should be as follows:
Expiry Date
23/3/2014,23/4/2014,23/5/2015
This is my insert Statement
cmd.CommandText = "INSERT INTO Customers (UserID, Validity, Amount, RegisteredDate,
ExpiryDate, FirstName, LastName, Address, State, City, Phone, Mobile, Email)
VALUES(@UserID,@Validity,@Amount,@RegisteredDate,@ExpiryDate,@FirstName,@LastName,
@Address,@State,@City,@Phone,@Mobile,@Email)"
This is my Update Statement:
cmd.CommandText = "UPDATE Customers SET UserID = @UserID, Validity = @Validity,
Amount = @Amount, RegisteredDate = @RegisteredDate, ExpiryDate = @ExpiryDate,
FirstName = @FirstName, LastName = @LastName , Address = @Address, State = @State,
City = @City, Phone = @Phone, Mobile= @Mobile, Email = @Email WHERE UserID = @UserID"
Upvotes: 0
Views: 534
Reputation: 31
If your ExpiryDate is defined in the database as a date field then the answer is you can't do that. However, if it defined as a string (which it should never be) then you can just concatenate the multiple expiry dates and store it as you would any other string. But I don't see how multiple expiry dates makes sense. But if, for some reason that isn't obvious multiple dates are valid and you want them stored as dates then you could define a separate table of expiry dates and store an ExpiryDateID in the first table and have a one-to-many relationship between the existing table and the new one.
Upvotes: 1