D
Dave
I have an old web app that ues an Access database and ASP 3.0.
I need to build an INSERT statement based on the contents of a form.
What is the best way to handle blank text boxes that are submitted with the
form?
For example, I collect all my name/value pairs that are submitted with the
form like this...
sExample=Request.Form("txaExample")
sNote=Request.Form("txtNote")
iSourceID=Request.Form("cboSourceID")
iPageNo=Request.Form("txtPageNo")
sSourceRef=Request.Form("txtSourceRef")
....and then I build my INSERT statement like this...
sSQL = "INSERT INTO example (example, sourceid, sourceref, pageno, note)"
sSQL = sSQL & " VALUES ('" & sExample & "', "
sSQL = sSQL & cstr(iSourceID) & ", "
sSQL = sSQL & "'" & sSourceRef & "', "
sSQL = sSQL & cstr(iPageNo) & ", "
sSQL = sSQL & "'" & sNote & "' "
sSQL = sSQL & ")"
....but if some of the controls are left blank, I get an INSERT atatement
llike this...
INSERT INTO example (example, sourceid, sourceref, pageno, note) VALUES
('asgfgdsfhg', 6, '', , '' )
What is the value when an empty control is submitted?
isempty and isnull both return false even though nothing was submitted with
the form. I can test for a zero length (IF len(Note)=0) but is this the
best way to test?
IOW, test each value for zero length and if true, set the value equal to
NULL to get something like this...
INSERT INTO example (example, sourceid, sourceref, pageno, note) VALUES
('asgfgdsfhg', 6, NULL,NULL ,NULL )
Thanks for any insights.
I need to build an INSERT statement based on the contents of a form.
What is the best way to handle blank text boxes that are submitted with the
form?
For example, I collect all my name/value pairs that are submitted with the
form like this...
sExample=Request.Form("txaExample")
sNote=Request.Form("txtNote")
iSourceID=Request.Form("cboSourceID")
iPageNo=Request.Form("txtPageNo")
sSourceRef=Request.Form("txtSourceRef")
....and then I build my INSERT statement like this...
sSQL = "INSERT INTO example (example, sourceid, sourceref, pageno, note)"
sSQL = sSQL & " VALUES ('" & sExample & "', "
sSQL = sSQL & cstr(iSourceID) & ", "
sSQL = sSQL & "'" & sSourceRef & "', "
sSQL = sSQL & cstr(iPageNo) & ", "
sSQL = sSQL & "'" & sNote & "' "
sSQL = sSQL & ")"
....but if some of the controls are left blank, I get an INSERT atatement
llike this...
INSERT INTO example (example, sourceid, sourceref, pageno, note) VALUES
('asgfgdsfhg', 6, '', , '' )
What is the value when an empty control is submitted?
isempty and isnull both return false even though nothing was submitted with
the form. I can test for a zero length (IF len(Note)=0) but is this the
best way to test?
IOW, test each value for zero length and if true, set the value equal to
NULL to get something like this...
INSERT INTO example (example, sourceid, sourceref, pageno, note) VALUES
('asgfgdsfhg', 6, NULL,NULL ,NULL )
Thanks for any insights.