Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases 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 June 19th, 2003, 02:59 AM
Registered User
 
Join Date: Jun 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem displaying one of the records.

Hi, i haf dis problem of displaying the records according to the id. Can anybody help me on dis? dis is wad i haf... wad m i missing or wer did i go wrong?

<%
Dim Conn, SQL, rs
Dim id, dept

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("emp.mdb")

sID=request.form("id")
SQL="Select * FROM Info WHERE CPAR_No='" & sID & "'"
set rs=Conn.Execute(SQL)

IF not rs.EOF Then
id=rs.Fields("ID")
dept=rs.Fields("Department")
response.write "cpar :" & id
response.write "dept :" & dept
else
response.write "No Record Found"
end if


set rs=Nothing
Conn.Close
set Conn=Nothing

%>
 
Old June 19th, 2003, 04:56 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 158
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to NotNowJohn
Default

If ID field in your table is an integer type you have to change SQL statement to:
SQL="Select * FROM Info WHERE CPAR_No=" & sID

...but the Soon is eclipsed by the Moon
 
Old June 19th, 2003, 07:35 PM
Registered User
 
Join Date: Jun 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

But mine is a text datatype... so wad else could be wrong? it keeps telling me there is no records found even tho there is such a record in my database.wad i need is to display the particular id & info of the employee wen the user enters the id.
 
Old June 20th, 2003, 02:53 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 111
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Change:

SQL="Select * FROM Info WHERE CPAR_No='" & sID & "'"

to

SQL="Select * FROM Info WHERE CPAR_No='" & sID & "'"
Response.Write(SQL)
Response.End

and post the output that you see to the list, so that we can have a look at your actual SQL statement

Cheers
Ken


www.adOpenStatic.com
 
Old June 20th, 2003, 03:12 AM
Registered User
 
Join Date: Jun 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Select * FROM Info WHERE CPAR_No='BCTD0001'

dis is wad i get... but sorry dis will show onli the sql sentence... it does not show me the records i wan...

& dis is my codes...

<%
Dim Conn, SQL, rs
Dim id, dept

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("CPAS.mdb")

sID=request.form("cparno")
SQL="Select * FROM Info WHERE CPAR_No='" & sID & "'"
Response.Write(SQL)
Response.End

IF not rs.EOF Then
id=rs.Fields("CPAR_No")
dept=rs.Fields("Department")
response.write "cpar :" & id
response.write "dept :" & dept
else
response.write "No Record Found"
end if

set rs=Nothing
Conn.Close
set Conn=Nothing

%>
 
Old June 24th, 2003, 08:56 PM
Authorized User
 
Join Date: Jun 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

try replacing the if statement with this...

While not rs.eof
  id=rs.Fields("ID")
  dept=rs.Fields("Department")
  response.write "cpar :" & id
  response.write "dept :" & dept
  rs.movenext
Wend





Similar Threads
Thread Thread Starter Forum Replies Last Post
Displaying Multiple Records on Report bnc111 Access 1 August 16th, 2007 02:10 PM
problem displaying records in order of time ,date method PHP Databases 3 July 25th, 2006 08:16 PM
Displaying records as hyperlinks chbravo Classic ASP Databases 1 December 6th, 2005 07:38 AM





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