Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding blank records to the database

Status
Not open for further replies.

gmagerr

Technical User
Aug 11, 2001
323
US
hi guys, i made a form that submits to 4 tables. the problem i'm having is if i just fill in one of the forms it adds a blank entry to each of the other tables from the forms that i didn't fill. does that make sense? so how would i make it so, if there is nothing in the form, nothing gets entered into the table? thanks in advance.
 
You need to use ASP to check for empty strings from the form fields and only update those tables where the data strings aren't empty like so:

if request.form(&quot;textfield1&quot;) <> &quot;&quot; then
'Run update database SQL query
end if

if request.form(&quot;textfield2&quot;) <> &quot;&quot; then
'Run update database SQL query
end if

and so on

<> is the same as using: not request.from(&quot;textfield&quot;) = &quot;&quot; Harold Blackorby
hblackorby@scoreinteractive.com
St. Louis, MO
 
Thanks i tried that and it still entered blank data.. here's one of the updates i'm using maybe you can have a look at it and make a suggestion. Thanks for the reply.

Set cnTelmon = Server.CreateObject(&quot;ADODB.Connection&quot;)
cnTelmon.Open &quot;DSN=Telmon&quot;

Set rsComp = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rsComp.Open &quot;Computers&quot;, cnTelmon, adOpenStatic, adLockOptimistic
rsComp.addnew

rsComp(&quot;SerialNo&quot;) = Request.Form(&quot;compSerialNo&quot;)
rsComp(&quot;Description&quot;) = Request.Form(&quot;compDescription&quot;)
rsComp(&quot;IssuedTo&quot;) = Request.Form(&quot;compIssuedTo&quot;)
rsComp(&quot;DateIssued&quot;) = Request.Form(&quot;compDateIssued&quot;)
rsComp(&quot;Notes&quot;) = Request.Form(&quot;compNotes&quot;)

rsComp.Update
rsComp.MoveLast
rsComp.Close
Set rsComp = Nothing

This is actually causing blank data to be entered into the database.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top