Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


ASP database access

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,2848
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> ASP database access
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 ASP database access - 5/1/2005 12:37:30 AM   
  greentea

 

Posts: 3
Score: 0
Joined: 4/30/2005
From: United Kingdom
Status: offline
Hi All, I am trying to write an ASP adds a user's details to a database, returns an ID called 'CustID'. At the moment CustID is returned in an alert box, which is a complete no no. I'm wondering if anyone can give me some guidance as to how to return the CustID and place it in a text input box on a form. The form is contained in the page 'index.html', the code for the ASP and the HTML page is below. Thanks in advance for anyone who takes the time.

<html>
<head><title>AddCustomer asp file</title></head>
<body bgcolor=#ffffff text = #000000>
<font color = "red">Redirecting to login page</font>

<%
dim conn, dbPath, dbConnect, SQL, RS
dbPath = Server.MapPath("Databases/project.mdb")
dbConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & dbPath
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open dbConnect
Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open "Customers", conn, 1, 3, 2
RS.AddNew
RS("FirstName") = Request.Form("txtFName")
RS("Surname") = Request.Form("txtSName")
RS("HouseName") = Request.Form("txtHouseName")
RS("Address") = Request.Form("txtAddress")
RS("City") = Request.Form("txtCity")
RS("Postcode") = Request.Form("txtPostcode")
RS("Telephone") = Request.Form("txtTel")
RS("Email") = Request.Form("txtEmail")
RS("Fund") = Request.Form("txtFund")
RS.Update
Dim CustID
CustID = RS("CustID")
RS.Close
set RS = nothing
conn.close
set conn = nothing

%>
<script language="javascript" type="text/javascript">
alert("Your Customer ID is '<%=CustID%>'");
window.location.href = "index.htm";
</script>
<%
%>
<br>
<br>
</body>
</html>

Index.htm:

<html>

<head>
<title>Login page</title>
</head>
<body>
<br>
<br>
<br>
<table border = "0" align = "center">
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td>
<h1 align = center>Please login or register</h1></td></tr><tr><td>
<table align = "center" border = "0" cellspacing = "10" cellpadding = "10"><tr><td>
<form method = "POST" name = "frmLogin" action = "CheckID.asp">
<p>Customer ID <input type = "text" name = "txtCustID" size = "10"></p></td><td>
<input type = "submit" value = "login" name = "btnLogin" OnClick = ""></tr>
</td></tr>
<tr><td align = "left"><a href="form.htm">Want to register?</a></td></tr>
<tr><td align = "left"><a href="AddToStock.htm">Want to update stock?</a></td></tr>
</table>
</table>



</body>
</html>
 
 
Post #: 1
 
 Re: ASP database access - 5/1/2005 2:41:30 AM   
  VBS

 

Posts: 110
Score: 0
Joined: 3/2/2005
From: Lebanon
Status: offline
Dear greentea,
If u want to use HTML Page, then i don't know, but if u use an ASP Page then use this code:


      

if u knew how to do it in HTML then i'll be appreciated if u post it, cause i really need it too...

Hope this helps


Best Regards
Firas S Assaad

(in reply to greentea)
 
 
Post #: 2
 
 Re: ASP database access - 5/3/2005 4:24:20 PM   
  greentea

 

Posts: 3
Score: 0
Joined: 4/30/2005
From: United Kingdom
Status: offline
Dear Firas, apologies for taking so long to reply. I tried what you said and it didn't seem to work. What happens is; when it redirects to index.htm after filling in form.htm the txtCustID box contains the text "<%=request.form("CustID")%" and strangely the tag closing ">" symbol is displayed outside the txtCustID box immediadetly after it. I've probably done something really stupid, please help.

Steven McArdle

ps I asked my lecturer about doing it in HTML and he said he'd look into it.

quote:
Originally posted by VBS

Dear greentea,
If u want to use HTML Page, then i don't know, but if u use an ASP Page then use this code:


      

if u knew how to do it in HTML then i'll be appreciated if u post it, cause i really need it too...

Hope this helps


Best Regards
Firas S Assaad


(in reply to greentea)
 
 
Post #: 3
 
 Re: ASP database access - 5/11/2005 7:38:18 AM   
  T1TAN23

 

Posts: 11
Score: 0
Joined: 5/11/2005
From: USA
Status: offline
try putting the value in quotes like so

<input type = "text" name = "txtCustID" size = "10" value="<%=request.form("CustID")%>">

and you don't need to use request.form("CustID") unless you have a cookie or a querystring with the same name accesable by the page. you can just do...

<input type = "text" name = "txtCustID" size = "10" value="<%=request("CustID")%>">

You should also try to response out the custID so that you cane see if the custID is being passed to the page like so

Response.Write Request("CustID") & "<br>" & vbcrlf
<input type = "text" name = "txtCustID" size = "10" value="<%=request("CustID")%>">


get in the habbit of using the response object for debugging and response out everything to make sure you are passing what you need to where you need to.

Hope this helps

(in reply to greentea)
 
 
Post #: 4
 
 Re: ASP database access - 5/11/2005 8:22:23 PM   
  VBS

 

Posts: 110
Score: 0
Joined: 3/2/2005
From: Lebanon
Status: offline
greentea wants to view the result in HTML page (*.htm) and not ASP (*.asp) so if he has to do the way u said, it will view the Code in the TextBox without runing it

(in reply to greentea)
 
 
Post #: 5
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> ASP database access Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts