S
sklett
Hi-
I have a problem and a proposed solution. In my DataGrid's update command,
there are some sections that may or may not be changed, for example
uploading a file. A user might edit the record and change the title of the
file stored, but might not upload a new file. I can't think of a clean way
to handle this type of situation w/out calling 2 different stored procedures
based on these different possible outcomes and that could get ugly fast.
Then I thought that I would conditionally execute UPDATES in the stored
procedure, for example:
if @FileName.Length <= 0
-- code to update everything BUT the file stuff
else
-- code to update file stuff as well.
Right away there is a problem. First of all, @FileName.Length is totally
made up, I don't know how to get the length of a parameter. Is that
possible? I see something called DATALENGTH in the online books, but that
doesn't seem to be the correct solution.
Second of all, if I had 20 optional pieces of data that may or may not have
changed, this could get to be really ugly. I know that I could store the
current filename, changed or unchanged, but that would cause an upload to
happen again unless I were to wrap everything up in a bunch of "Are you a
new value?" logic in my UpdateEvent. I would rather ship everything off to
the stored procedure and let it worry about everything...
So, what do I want? What is the best way? Am I going about this all wrong?
Please advise and help if possible, I'm not sure where to go from here and I
want to do it right.
Thanks,
Steve
I have a problem and a proposed solution. In my DataGrid's update command,
there are some sections that may or may not be changed, for example
uploading a file. A user might edit the record and change the title of the
file stored, but might not upload a new file. I can't think of a clean way
to handle this type of situation w/out calling 2 different stored procedures
based on these different possible outcomes and that could get ugly fast.
Then I thought that I would conditionally execute UPDATES in the stored
procedure, for example:
if @FileName.Length <= 0
-- code to update everything BUT the file stuff
else
-- code to update file stuff as well.
Right away there is a problem. First of all, @FileName.Length is totally
made up, I don't know how to get the length of a parameter. Is that
possible? I see something called DATALENGTH in the online books, but that
doesn't seem to be the correct solution.
Second of all, if I had 20 optional pieces of data that may or may not have
changed, this could get to be really ugly. I know that I could store the
current filename, changed or unchanged, but that would cause an upload to
happen again unless I were to wrap everything up in a bunch of "Are you a
new value?" logic in my UpdateEvent. I would rather ship everything off to
the stored procedure and let it worry about everything...
So, what do I want? What is the best way? Am I going about this all wrong?
Please advise and help if possible, I'm not sure where to go from here and I
want to do it right.
Thanks,
Steve