|
 |
asp_databases thread: Inserting nulls
Message #1 by "Vic" <vweston@m...> on Thu, 25 Apr 2002 16:21:29
|
|
On page one I have a form that collects inforamtion about a new user. This
information is passed to page two like so:
<%
fname= request.form("fname")
sname= request.form("sname")
title1 = request.form("job")
title2 = request.form("titlenew")
dept_id = request.form("dept")
loc_id = request.form("loc")
extension= request.form("ext")
companymobile= request.form("mobile")
email= request.form("email")
photo= request.form("photo")
if title1 = "Select..." then
title = request.form("titlenew")
else
title = request.form("job")
end if
DIM objconn
set objconn = server.createobject("ADODB.Connection")
objconn.open = strcon
sqlrs = "Insert into people_listvic (fname, sname, loc_id, title, dept_id,
extension, email, companymobile, photo) VALUES
('"&fname&"','"&sname&"','"&loc_id&"','"&title&"','"&dept_id&"','"&extensio
n&"','"&email&"','"&companymobile&"','"&photo&"')"
objconn.execute sqlrs
%>
Not all of the fields are required, so some of them are left blank on page
one. These fields are inserted as blank fields and not <NULL>, which is
what I want as I use the NULL values in another page for displaying
information.
I am using MS SQLServer. Also, I'm not very experienced, so please explain
as if you are talking to an idiot. Thanks very much.
Message #2 by "Drew, Ron" <RDrew@B...> on Thu, 25 Apr 2002 13:19:08 -0400
|
|
Not sure if I completely understand. If you want to insert a space if
the form field is not entered.
Use IsNull function - syntax:
If IsNull(objField.Value) then
Response.Write(" ")
End If
-----Original Message-----
From: Vic [mailto:vweston@m...]
Sent: Thursday, April 25, 2002 12:21 PM
To: ASP Databases
Subject: [asp_databases] Inserting nulls
On page one I have a form that collects inforamtion about a new user.
This
information is passed to page two like so:
<%
fname=3D request.form("fname")
sname=3D request.form("sname")
title1 =3D request.form("job")
title2 =3D request.form("titlenew")
dept_id =3D request.form("dept")
loc_id =3D request.form("loc")
extension=3D request.form("ext")
companymobile=3D request.form("mobile")
email=3D request.form("email")
photo=3D request.form("photo")
if title1 =3D "Select..." then
title =3D request.form("titlenew")
else
title =3D request.form("job")
end if
DIM objconn
set objconn =3D server.createobject("ADODB.Connection")
objconn.open =3D strcon
sqlrs =3D "Insert into people_listvic (fname, sname, loc_id, title,
dept_id,
extension, email, companymobile, photo) VALUES
('"&fname&"','"&sname&"','"&loc_id&"','"&title&"','"&dept_id&"','"&exten
sio
n&"','"&email&"','"&companymobile&"','"&photo&"')"
objconn.execute sqlrs
%>
Not all of the fields are required, so some of them are left blank on
page
one. These fields are inserted as blank fields and not <NULL>, which is
what I want as I use the NULL values in another page for displaying
information.
I am using MS SQLServer. Also, I'm not very experienced, so please
explain
as if you are talking to an idiot. Thanks very much.
Message #3 by "Vic" <vweston@m...> on Fri, 26 Apr 2002 09:33:53
|
|
> Not sure if I completely understand. If you want to insert a space if
the form field is not entered.
Use IsNull function - syntax:
If IsNull(objField.Value) then
Response.Write(" ")
End If
sorry - probably was not as clear as I should have been. What I want to do
is insert nulls into the fields that are left empty by the person filling
in the form. What happens at the moment is that when a field is left
empty, a blank entry goes into the database and not a null value.
--Original Message-----
From: Vic [mailto:vweston@m...]
Sent: Thursday, April 25, 2002 12:21 PM
To: ASP Databases
Subject: [asp_databases] Inserting nulls
On page one I have a form that collects inforamtion about a new user.
This
information is passed to page two like so:
<%
fname=3D request.form("fname")
sname=3D request.form("sname")
title1 =3D request.form("job")
title2 =3D request.form("titlenew")
dept_id =3D request.form("dept")
loc_id =3D request.form("loc")
extension=3D request.form("ext")
companymobile=3D request.form("mobile")
email=3D request.form("email")
photo=3D request.form("photo")
if title1 =3D "Select..." then
title =3D request.form("titlenew")
else
title =3D request.form("job")
end if
DIM objconn
set objconn =3D server.createobject("ADODB.Connection")
objconn.open =3D strcon
sqlrs =3D "Insert into people_listvic (fname, sname, loc_id, title,
dept_id,
extension, email, companymobile, photo) VALUES
('"&fname&"','"&sname&"','"&loc_id&"','"&title&"','"&dept_id&"','"&exten
sio
n&"','"&email&"','"&companymobile&"','"&photo&"')"
objconn.execute sqlrs
%>
Not all of the fields are required, so some of them are left blank on
page
one. These fields are inserted as blank fields and not <NULL>, which is
what I want as I use the NULL values in another page for displaying
information.
I am using MS SQLServer. Also, I'm not very experienced, so please
explain
as if you are talking to an idiot. Thanks very much.
Message #4 by "Drew, Ron" <RDrew@B...> on Fri, 26 Apr 2002 08:30:12 -0400
|
|
You can check the value of the request.form and set it to null if it
comes in as spaces...see..
http://www.asp101.com/resources/visitors/viewasp.asp?file=3DDBRoutines%2E
a
sp
-----Original Message-----
From: Vic [mailto:vweston@m...]
Sent: Friday, April 26, 2002 5:34 AM
To: ASP Databases
Subject: [asp_databases] RE: Inserting nulls
> Not sure if I completely understand. If you want to insert a space if
the form field is not entered.
Use IsNull function - syntax:
If IsNull(objField.Value) then
Response.Write(" ")
End If
sorry - probably was not as clear as I should have been. What I want to
do
is insert nulls into the fields that are left empty by the person
filling
in the form. What happens at the moment is that when a field is left
empty, a blank entry goes into the database and not a null value.
--Original Message-----
From: Vic [mailto:vweston@m...]=3D20
Sent: Thursday, April 25, 2002 12:21 PM
To: ASP Databases
Subject: [asp_databases] Inserting nulls
On page one I have a form that collects inforamtion about a new user.
This=3D20 information is passed to page two like so: <% fname=3D3D
request.form("fname") sname=3D3D request.form("sname") title1 =3D3D
request.form("job") title2 =3D3D request.form("titlenew") dept_id =3D3D
request.form("dept") loc_id =3D3D request.form("loc") extension=3D3D
request.form("ext") companymobile=3D3D request.form("mobile") email=3D3D
request.form("email") photo=3D3D request.form("photo")
if title1 =3D3D "Select..." then
title =3D3D request.form("titlenew")
else
title =3D3D request.form("job")
end if
DIM objconn
set objconn =3D3D server.createobject("ADODB.Connection")
objconn.open =3D3D strcon
sqlrs =3D3D "Insert into people_listvic (fname, sname, loc_id, title,
dept_id,=3D20 extension, email, companymobile, photo) VALUES=3D20
('"&fname&"','"&sname&"','"&loc_id&"','"&title&"','"&dept_id&"','"&exten
sio
n&"','"&email&"','"&companymobile&"','"&photo&"')"
objconn.execute sqlrs
%>
Not all of the fields are required, so some of them are left blank on
page=3D20 one. These fields are inserted as blank fields and not <NULL>,
which is=3D20 what I want as I use the NULL values in another page for
displaying=3D20 information.
I am using MS SQLServer. Also, I'm not very experienced, so please
explain=3D20 as if you are talking to an idiot. Thanks very much.
---
Change your mail options at http://p2p.wrox.com/manager.asp or=3D20 to
unsubscribe send a blank email to
Message #5 by shawnc@u... on Tue, 30 Apr 2002 00:24:13
|
|
Watch the wrapping on that link, otherwise you'll need to do something
like this:
if len(request("valuefield")) = 0 then
strValueToInsert = "NULL"
else
strValueToInsert = "'" & request("valuefield") & "'"
end if
or you can also just leave the field out of the insert statement if the len
() = 0
I'd recommend writing a function like CheckForNull() (note: this is not a
built-in function) that does this checking for every field you insert.
Shawn
> > You can check the value of the request.form and set it to null if it
c> omes in as spaces...see..
h> ttp://www.asp101.com/resources/visitors/viewasp.asp?file=3DDBRoutines%
2E
a>
s> p
>
> Thanks for all your help, but I can't seem to get this link to work.
Message #6 by "Vic" <vweston@m...> on Mon, 29 Apr 2002 12:58:09
|
|
> You can check the value of the request.form and set it to null if it
comes in as spaces...see..
http://www.asp101.com/resources/visitors/viewasp.asp?file=3DDBRoutines%2E
a
sp
Thanks for all your help, but I can't seem to get this link to work.
|
|
 |