Thank you.

> From reading your response I'm thinking that your passing the value of
> the textbox straight to your update SQL before doing any input
> validation on it.  This is NOT a good way to do things as it can allow
> for malicious attacks against your code.

You're correct, but this is a small company and it's a simple internal
app so I'm not so worried about malicious attacks, however since i'm
obviously in the formitable learning stage, I should learn and do it
correct so i'll do that.

> What you should do is validate your inputs before sending them to your
> tableadapter update command.  At this point check to see if the text
> box is empty.  If it is, pass DBNull.Value as the variable value to
> the tableadapter update command.
>
That makes sense.  Thank you for the explination.

> What you're trying to do is not as simple as 'just setting the textbox
> field to null and then saving the updated data.

you can say that again!!!!  seems like it would be easy enough to
change a value to null, but i guess it's more like pulling teeth and
then trying to put them back in.

I think what was confusing me most is that when i went into the same
datagridview I used to select the FK and selected the null value, it
would remove the location from the form.  What it was doing was
grabbing the PK from the datagridview that was auto generating when i
clicked into that row and assigning that to the textbox.  That was a
empty record, so nothing was showing on my form (It looked like no
location was being selected).  I double checked in the sql server and
sure enough it was not writing a Null Value to it (of course you
already knew that), It was writing an integer.  That's of course why I
couldn't write DBNull to the field from a button event (again, you
already knew that).


' DBNull is not a
> string which is what a textbox requires for input, which is why you
> can't just set the textbox field to null.
>

I'll take your advice and set the field to nothing and on validation
set any field that's blank to dbnull.

Thanks very much for taking time out to help me.  Hope that I didn't
pop too many vein's in anyone's forehead :).

Reply via email to