Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 28th, 2003, 08:31 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Well, in that case (if the INSERT seems to work correctly), simply change the value of Box_ID right before you pass it to the database. In your example you padded FullMedlID with leading zeros, but then use Var1 (nice, descriptive variable name, BTW ;) ) for the SQL statement:

Code:
' Before we construct and pass the SQL statement, modify
' the value of Var1 so it is padded with zeros.

' Var1 comes from Request.QueryString("FullMedlID")
' Now padd it with zeros
Var1 = Right("00000" & Var1, 5)

' And then insert Var1 together with the other variables in the database.

'SQL Statement
SQL = "INSERT INTO Box_ID (BoxID, FirstName, LastName, Adress, PostNr, PostAdress, EmailAdress, PassWord, TelNr, Fnr, MFID)"
SQL = SQL & "VALUES ('" & Var1 & "'"
SQL = SQL & " ,'" & Var2 & "'"
SQL = SQL & " ,'" & Var3 & "'"
SQL = SQL & " ,'" & Var4 & "'"
SQL = SQL & " ,'" & Var5 & "'"
SQL = SQL & " ,'" & Var6 & "'"
SQL = SQL & " ,'" & Var7 & "'"
SQL = SQL & " ,'" & Var8 & "'"
SQL = SQL & " ,'" & Var9 & "'"
SQL = SQL & " ,'" & Var10 & "'"
SQL = SQL & " ,'" & Var11 & "')"

' Utför sql statement
Set RS = Cn.Execute(SQL)
If all works out as expected, the database column BoxID should now contain 00035.


HtH

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old August 28th, 2003, 09:25 AM
Authorized User
 
Join Date: Aug 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am not so stupid after all... god I love trial and error ;) Got this sweet baby to work after all.
Thanks for all your help.

<%
'FÃ¥ in "Form" variabler
Var1=request.querystring("BoxID")
Var1 = Right("00000" & Var1, 5)
Var2=request.querystring("Fornamn")
Var3=request.querystring("Efternamn")
Var4=request.querystring("Adress")
Var5=request.querystring("Pnr")
Var6=request.querystring("Postadress")
Var7=request.querystring("Email")
Var8=request.QueryString("PassWord")
Var9=request.QueryString("Telefon")
Var10=request.QueryString("Fnr")
Var11=request.QueryString("MFID")
Var11 = Right("00000" & Var11, 5)

Set Cn=Server.CreateObject("ADODB.Connection")
Cn.Open = "DSN=Flamer"

'SQL Statement
SQL = "INSERT INTO Box_ID (BoxID, FirstName, LastName, Adress, PostNr, PostAdress, EmailAdress, PassWord, TelNr, Fnr, MFID)"
SQL = SQL & "VALUES('" & Var1 & "'" a s o
 
Old September 9th, 2003, 02:30 AM
Authorized User
 
Join Date: Aug 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Funny thing is... since I am using Access I don't have to use code to do this. I just set a mask and now it works great.










Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.