| Author |
Topic |
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2010-03-17 : 11:30:56
|
If a person doesn't enter a date in the date field this goes into the DB 1/1/1900 12:00:00 AMHow can I get the word NULL to go into the DB when a date isn't entered into the date field?I just need it for the these two highlighted below:@DteToFO datetime,@DteBack datetime,Thanks!ALTER procedure [dbo].[UpdateClaimant]@Claim char(6),@PIC char(2),@FinalLaf varchar(2),@DteIn datetime,@Remarks varchar(255),@BICAdj varchar(3),@NoBIC varchar(255),@IA int,@FD int,@DteToFO datetime,@DteBack datetime,@Results int,@Amt moneyAS update TestDataset [Claim] = @Claim,[PIC] = @PIC,[FinalLaf] = @FinalLaf,[DteIn] = @DteIn,[Remarks] = @Remarks,[BICAdj] = @BICAdj,[NoBIC] = @NoBIC,[IA] = @IA,[FD] = @FD,[DteToFO] = @DteToFO,[DteBack] = @DteBack,[Results] = @Results,[Amt] = @AmtWhere claim=@claim and pic=@pic |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-17 : 11:35:01
|
| pass NULL value explicitly for date parameters------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2010-03-17 : 11:39:43
|
| Thank you so much for helping me. I'm working on a project that's due today. Thanks that worked! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-17 : 11:42:18
|
| welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2010-03-17 : 11:42:36
|
Back again I added this to the stored procedure:[DteToFO] = NULL,[DteBack] = NULL,So when I went back to add a date it didn't add it. What am I doing wrong? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-17 : 11:43:49
|
| can you show the insert code?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2010-03-17 : 11:46:31
|
I tried this but it didn't work:if dtetofo = "" then[DteToFO] = NULL,else[DteToFO] = @DteToFO, ALTER procedure [dbo].[UpdateClaimant]@Claim char(6),@PIC char(2),@FinalLaf varchar(2),@DteIn datetime,@Remarks varchar(255),@BICAdj varchar(3),@NoBIC varchar(255),@IA int,@FD int,@DteToFO datetime,@DteBack datetime,@Results int,@Amt moneyAS update TestDataset [Claim] = @Claim,[PIC] = @PIC,[FinalLaf] = @FinalLaf,[DteIn] = @DteIn,[Remarks] = @Remarks,[BICAdj] = @BICAdj,[NoBIC] = @NoBIC,[IA] = @IA,[FD] = @FD,[DteToFO] = @DteToFO,[DteBack] = @DteBack,[Results] = @Results,[Amt] = @AmtWhere claim=@claim and pic=@pic |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-17 : 11:50:55
|
| is that if ..else inside sql? or is that front end code?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2010-03-17 : 11:53:25
|
| Yes it's in sql. I tried this but Incorrect syntax near the keyword 'CASE'.ALTER procedure [dbo].[UpdateClaimant]@Claim char(6),@PIC char(2),@FinalLaf varchar(2),@DteIn datetime,@Remarks varchar(255),@BICAdj varchar(3),@NoBIC varchar(255),@IA int,@FD int,@DteToFO datetime,@DteBack datetime,@Results int,@Amt moneyAS update TestDataset [Claim] = @Claim,[PIC] = @PIC,[FinalLaf] = @FinalLaf,[DteIn] = @DteIn,[Remarks] = @Remarks,[BICAdj] = @BICAdj,[NoBIC] = @NoBIC,[IA] = @IA,[FD] = @FD,CASE WHEN (dtetofo)= Null THEN Null ELSE [DteToFO] = @DteToFO end,[DteBack] = @DteBack,[Results] = @Results,[Amt] = @AmtWhere claim=@claim and pic=@pic |
 |
|
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2010-03-17 : 12:19:30
|
Figured it out...I added it to the front end: If DteToFOtxt.Text = "" Then .Parameters.AddWithValue("@DteToFO", DBNull.Value) Else .Parameters.AddWithValue("@DteToFO", DteToFOtxt.Text) End If If DteFromtxt.Text = "" Then .Parameters.AddWithValue("@DteBack", DBNull.Value) Else .Parameters.AddWithValue("@DteBack", DteFromtxt.Text) End If |
 |
|
|
|
|
|