|
-
June 3rd, 1999, 10:24 AM
#1
URGENT.SQLServer,NULLS And Foreign Keys.
Some days ago I sent a question and I cannot believe nobody has found this problem.
I post it again because any suggestion would be appreciated. Thanks!!!
The trouble is the following:
I have a SQLServer table. One of the fields corresponds with a foreign key value. But it may
be a null value.I mean, it may be a null value, but if it is not, it may correspond with one of the values of the foreign key
I have a DataCombo bound to this field. If I don´t edit the field, nothing happens when I update. A null value is correctly stored.
But if the user edits the value and decides he
wants to cancel edit (Backspace, or blanks " ")
when I update SQLSErver says "" or " " is not a
correct foreign key!!!
I tried, before updating the value (WillMove event), to set a NULL
value if the value is a blank. But sometimes i don´t have the control of every update - i have
Grids and other bound objects-
Otherwise, i cannot store a NULL value in a combobox.
Is there any way to do this, any option in Database design that doesn´t make me control it
using Database triggers?
Thanks in advance
JaIme
-
June 3rd, 1999, 12:08 PM
#2
Re: URGENT.SQLServer,NULLS And Foreign Keys.
The only thing I can think of is to set the ListIndex Property of your combobox to -1
-
June 4th, 1999, 03:05 AM
#3
Re: URGENT.SQLServer,NULLS And Foreign Keys.
Mmmm...It would be easy but will never work.I'm working with datacombos and they don´t have the listindex property.
Thanks anyway,Cary
-
June 4th, 1999, 07:19 AM
#4
Re: URGENT.SQLServer,NULLS And Foreign Keys.
Ok, someday I will have to learn to read ;-)
Try setting the DataChanged property to False in the Validate Event.
-
June 14th, 1999, 01:10 PM
#5
Re: URGENT.SQLServer,NULLS And Foreign Keys.
TRY THIS CODE, IT WORKS FOR ME, THIS IS IF YOU USE A FK WITH NULL VALUE, YOU MUST BE USING SQL COMMANDS
FOR INSERT AND UPDATE COMMAND
REFERENCES
1.- txtname (TEXT BOX FOR CHAR)
'" & iif (Trim(txtname)="","NULL",txtname) & "'
WHEN YOU TRY TO OPEN A RECORDSET PROBABLY YOU WILL RECIEVE AN ERROR THAT SAYS THAT THE COLUMN xxxx CAN HAVE NULL VALUES SO IN VB WHEN YOU OPEN THE RECORDSET USE THIS COMMAND
IIf(IsNull(rs("CPHONENUMBER")), "", rs("CPHONENUMBER"))
TRY IT WILL HELP YOU, ANY PROBLEM ASK ME FOR MORE HELP
REGARDS
-
June 14th, 1999, 01:12 PM
#6
Re: URGENT.SQLServer,NULLS And Foreign Keys.
BY THE WAY, I USE THIS IN VB USING SQL AS DATABASE, WITH MORE THAN 300 TABLES, USING IN ONE TABLE 32 FK'S
REGARDS
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|