Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 09:53 AM
Massa
Guest
 
Posts: n/a
Default ASP Database Help

Hi all,
I need some help on this one:
I have a webpage with a form. This form submits data that goes to a mdb file
(id (AutoNumber), name, email contry etc.). I would like to make another
page where I can type the ID number and it will show all the fields only for
that id.
I hope I've been clear enough...
Thanks a lot for you help.

Massa


  #2  
Old July 19th, 2005, 09:53 AM
Dan Brussee
Guest
 
Posts: n/a
Default Re: ASP Database Help

On Mon, 1 Dec 2003 21:37:23 -0200, "Massa" <massabr@ig.com.br> wrote:
[color=blue]
>Hi all,
>I need some help on this one:
>I have a webpage with a form. This form submits data that goes to a mdb file
>(id (AutoNumber), name, email contry etc.). I would like to make another
>page where I can type the ID number and it will show all the fields only for
>that id.
>I hope I've been clear enough...
>Thanks a lot for you help.
>[/color]

Very clear... where do you need help? Give some specific areas. I
assume since you can save the data, you can make a data connection,
etc.
  #3  
Old July 19th, 2005, 09:53 AM
Tom B
Guest
 
Posts: n/a
Default Re: ASP Database Help

I assume you are successfully saving the data.

Dim sSQL
Dim oRS
Dim lngID
lngID=Request.Form("theID") 'I assume you have a form that submits the id
number

sSQL="SELECT columnName1, columnName2 FROM tableName WHERE primaryIDField="
& lngID

Set oRS=validConnectionObject.Execute(sSQL)
if not oRS.EOF then
Response.write "<table><tr><th>Column1</th><th>Column2</th></tr>" &
vbCrLf
Do While not oRS.EOF
Response.Write "<tr><td>" & oRS.Fields("columnName1") & "</td><td>"
& oRS.Fields("columnName2") & "</td></tr>" & vbCrLf

RS.MoveNext
Loop
Response.Write "</table>" & vbCrLf
end if
Set oRS=Nothing

"Massa" <massabr@ig.com.br> wrote in message
news:1070321845.552778@gorgo.centroin.com.br...[color=blue]
> Hi all,
> I need some help on this one:
> I have a webpage with a form. This form submits data that goes to a mdb[/color]
file[color=blue]
> (id (AutoNumber), name, email contry etc.). I would like to make another
> page where I can type the ID number and it will show all the fields only[/color]
for[color=blue]
> that id.
> I hope I've been clear enough...
> Thanks a lot for you help.
>
> Massa
>
>[/color]


  #4  
Old July 19th, 2005, 09:53 AM
Massa
Guest
 
Posts: n/a
Default Re: ASP Database Help

I can't figure out how to make this page where I type the ID number (with a
ok button).
Thanks
Massa


"Dan Brussee" <dbrussee@nc.rr.com> wrote in message
news:peknsv8o93ra4c3d2uml5qv2dutqm49i5d@4ax.com...[color=blue]
> On Mon, 1 Dec 2003 21:37:23 -0200, "Massa" <massabr@ig.com.br> wrote:
>[color=green]
> >Hi all,
> >I need some help on this one:
> >I have a webpage with a form. This form submits data that goes to a mdb[/color][/color]
file[color=blue][color=green]
> >(id (AutoNumber), name, email contry etc.). I would like to make another
> >page where I can type the ID number and it will show all the fields only[/color][/color]
for[color=blue][color=green]
> >that id.
> >I hope I've been clear enough...
> >Thanks a lot for you help.
> >[/color]
>
> Very clear... where do you need help? Give some specific areas. I
> assume since you can save the data, you can make a data connection,
> etc.[/color]


  #5  
Old July 19th, 2005, 09:53 AM
Massa Massa
Guest
 
Posts: n/a
Default Re: ASP Database Help

I am sorry for this newbie question... but where do I past this?

Dim sSQL
Dim oRS
Dim lngID
lngID=Request.Form("theID") 'I assume you have a form that submits the
id
number

sSQL="SELECT columnName1, columnName2 FROM tableName WHERE
primaryIDField="
& lngID

Set oRS=validConnectionObject.Execute(sSQL)
if not oRS.EOF then
Response.write "<table><tr><th>Column1</th><th>Column2</th></tr>" &
vbCrLf
Do While not oRS.EOF
Response.Write "<tr><td>" & oRS.Fields("columnName1") & "</td><td>"
& oRS.Fields("columnName2") & "</td></tr>" & vbCrLf

RS.MoveNext
Loop
Response.Write "</table>" & vbCrLf
end if
Set oRS=Nothing


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #6  
Old July 19th, 2005, 09:53 AM
Bhaskardeep Khaund
Guest
 
Posts: n/a
Default Re: ASP Database Help

Hi,

Create a pgae with a textbox and a submit button. Then request the id into a varibale and then file an sql statement using the where clause on the ASP page and then get the data. Like

<%
Dim id, objRs

id = Trim(Request.Form("id"))

sql = "select * from table_name where id = "&id&""

Set objRs = Server.CreateObject("ADODB.Recordset")
objRs.Open sql, objConn
while not objrs.EOF
Resoponse.Write objRs("name")
.....blah blah
objrs.MoveNext
Wend

%>


Regards,
Bhaskardeep Khaund
  #7  
Old July 19th, 2005, 09:53 AM
Jeff Cochran
Guest
 
Posts: n/a
Default Re: ASP Database Help

On Mon, 1 Dec 2003 22:37:41 -0200, "Massa" <massabr@ig.com.br> wrote:
[color=blue]
>I can't figure out how to make this page where I type the ID number (with a
>ok button).[/color]

A form, with a text entry box and a submit button. In your ASP that
processes that form, do a SELECT with that ID in the WHERE clause.

This is actually pretty basic, but I'd prefer not to write it
completely for you and have you figure it out so you'll learn it. It
may look something like this:

Form:
================
<html>
<head><title>Show Record</title></head>
<body>
<P><form action="ShowRecord.asp">
Show Record Number: <input type="text" size="8" name="RecordID"><BR>
<input type="submit" name="Submit" value="Show Record">
</form></P>
</body></html>


ShowRecord.asp:
=================

' Get the record ID from form
RecordID = Request.Form("RecordID")

' create the actual SQL statement to do what you ask
SQLStmt = "SELECT * FROM tblTable WHERE RecordID =" & RecordID

' Create the database connection
dbConnect = (Put your connection string here)
Set db = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
db.Open dbConnect

' Run the Query
Set rs = db.Execute(SQLstmt)

' Now display the query results in whatever format you wish...


There are plenty of ways to modify this, but the basics are here.
It's sloppy and there are better methods you'll want to learn for this
type of request, you might check some of these links for suggestions
and tutorials:

http://www.sqlcourse.com/
http://www.learnasp.com/learnasp/ (Database section to start)
http://www.aspfaq.com/show.asp?id=2424
http://www.tutorial-web.com/asp/database/
http://www.asp-help.com/database/db_tutorial1.asp

And Google for more... :)

Jeff



[color=blue]
>"Dan Brussee" <dbrussee@nc.rr.com> wrote in message
>news:peknsv8o93ra4c3d2uml5qv2dutqm49i5d@4ax.com.. .[color=green]
>> On Mon, 1 Dec 2003 21:37:23 -0200, "Massa" <massabr@ig.com.br> wrote:
>>[color=darkred]
>> >Hi all,
>> >I need some help on this one:
>> >I have a webpage with a form. This form submits data that goes to a mdb[/color][/color]
>file[color=green][color=darkred]
>> >(id (AutoNumber), name, email contry etc.). I would like to make another
>> >page where I can type the ID number and it will show all the fields only[/color][/color]
>for[color=green][color=darkred]
>> >that id.
>> >I hope I've been clear enough...
>> >Thanks a lot for you help.
>> >[/color]
>>
>> Very clear... where do you need help? Give some specific areas. I
>> assume since you can save the data, you can make a data connection,
>> etc.[/color]
>[/color]

  #8  
Old July 19th, 2005, 09:54 AM
Massa
Guest
 
Posts: n/a
Default Re: ASP Database Help

Like this?
Thanks for your help

Massa

<html>
<head>
<title>TEST</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body><form action="" method="get" >
ID
<input type="text" name="textfield">
<input type="submit" name="Submit" value="Submit">
<%
Dim id, objRs

id = Trim(Request.Form("id"))

sql = "select * from table_name where id = "&id&""

Set objRs = Server.CreateObject("ADODB.Recordset")
objRs.Open sql, objConn
while not objrs.EOF
Resoponse.Write objRs("name")
.....blah blah
objrs.MoveNext
Wend

%>

</form>

</body>
</html>

"Bhaskardeep Khaund" <bhaskar_999@hotmail.com> wrote in message news:eyRN7ALuDHA.1596@TK2MSFTNGP10.phx.gbl...
Hi,

Create a pgae with a textbox and a submit button. Then request the id into a varibale and then file an sql statement using the where clause on the ASP page and then get the data. Like

<%
Dim id, objRs

id = Trim(Request.Form("id"))

sql = "select * from table_name where id = "&id&""

Set objRs = Server.CreateObject("ADODB.Recordset")
objRs.Open sql, objConn
while not objrs.EOF
Resoponse.Write objRs("name")
.....blah blah
objrs.MoveNext
Wend

%>


Regards,
Bhaskardeep Khaund
  #9  
Old July 19th, 2005, 09:54 AM
Mr Typhoon
Guest
 
Posts: n/a
Default ASP Database Help

[color=blue]
>-----Original Message-----
>Hi all,
>I need some help on this one:
>I have a webpage with a form. This form submits data that[/color]
goes to a mdb file[color=blue]
>(id (AutoNumber), name, email contry etc.). I would like[/color]
to make another[color=blue]
>page where I can type the ID number and it will show all[/color]
the fields only for[color=blue]
>that id.
>I hope I've been clear enough...
>Thanks a lot for you help.
>
>Massa
>
>
>.
>[/color]
You Must Use "Sesion" Method to solve your problem.U can
find a lot of scripts if u search asp pages for session
samples so maybe then u can find it there
if i can help u i will be glad.
  #10  
Old July 19th, 2005, 09:55 AM
Bhaskardeep Khaund
Guest
 
Posts: n/a
Default Re: ASP Database Help

Hi,

No, Make two different pages...it would be easier for u...........

Page1.asp

<html>
<head>
<title>TEST</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body><form action="Page2.asp" method="post" >
ID
<input type="text" name="id">
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>


Page2.asp
<html>
<head><title></title></head>
<body>
<table width="80%" align="center">
<%
Dim id, objRs
id = Trim(Request.Form("id"))
sql = "select * from table_name where id = "&id&""
Set objRs = Server.CreateObject("ADODB.Recordset")
objRs.Open sql, objConn
while not objrs.EOF
%>
<tr>
<td><%=objRs("firstname")%></td>
<td><%=objRs("address")%></td>
.......
</tr>
<%objrs.MoveNext
Wend
%>
</table>
</body>
</html>
<%Set objRs = Nothing %>
  #11  
Old July 19th, 2005, 09:55 AM
Tom B
Guest
 
Posts: n/a
Default Re: ASP Database Help

Also, you didn't create a connection object.
You referred to objConn so you need to add a couple of lines

Dim objConn
Set objConn=CreateObject("ADODB.Connection")
objConn.Open "a valid connection string... refer to
www.connectionstrings.com


Then you can do your
objRS.Open sql,objConn

although I prefer

Set objRS=objConn.Execute(sql)

and of course, remember to close and release your objects
objRS.Close 'if you used the objRS.open method
objConn.Close
Set objRS=nothing
Set objConn=nothing

"Bhaskardeep Khaund" <bhaskar_999@hotmail.com> wrote in message
news:%23lqRPzZuDHA.3140@TK2MSFTNGP11.phx.gbl...
Hi,

No, Make two different pages...it would be easier for u...........

Page1.asp

<html>
<head>
<title>TEST</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body><form action="Page2.asp" method="post" >
ID
<input type="text" name="id">
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>


Page2.asp
<html>
<head><title></title></head>
<body>
<table width="80%" align="center">
<%
Dim id, objRs
id = Trim(Request.Form("id"))
sql = "select * from table_name where id = "&id&""
Set objRs = Server.CreateObject("ADODB.Recordset")
objRs.Open sql, objConn
while not objrs.EOF
%>
<tr>
<td><%=objRs("firstname")%></td>
<td><%=objRs("address")%></td>
.......
</tr>
<%objrs.MoveNext
Wend
%>
</table>
</body>
</html>
<%Set objRs = Nothing %>


  #12  
Old July 19th, 2005, 09:55 AM
Bhaskardeep Khaund
Guest
 
Posts: n/a
Default Re: ASP Database Help

Hi,

Ya i know that...i wote 'Set your Connection Object'.....and i guess anybody can do that...i dont need to write....


Bhaskardeep Khaund
  #13  
Old July 19th, 2005, 09:57 AM
Tom B
Guest
 
Posts: n/a
Default Re: ASP Database Help

Sorry, I meant to reply to Massa's post, not yours.

"Bhaskardeep Khaund" <bhaskar_999@hotmail.com> wrote in message
news:unwgpBauDHA.1740@TK2MSFTNGP12.phx.gbl...
Hi,

Ya i know that...i wote 'Set your Connection Object'.....and i guess anybody
can do that...i dont need to write....


Bhaskardeep Khaund


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles