Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 output x amount of characters in one specific fiel
 New Topic  Topic Locked
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

skyhawks
Junior Member

USA
125 Posts

Posted - 28 February 2002 :  15:41:21  Show Profile  Visit skyhawks's Homepage
Is there a way i can output x amount of characters in one specific field in my access database?? what i mean is that in my REVIEW. its a long paragraph. nad I only want to display the first sentence... and i will follow with a link to see more info for that record.

thanks.

sky

<%
dim conn
dim rs
dim strsql

set conn=server.CreateObject("adodb.connection")
set rs=server.CreateObject("adodb.recordset")
conn.open "newyorkdb"
strsql = "Select * FROM moviereview"
rs.open strsql, conn
%>

<p><img src="/posters/<%= rs("imgposter") %>" border=0><br>
<b><%= rs("movietitle") %></b><br>
<%= rs("review") %> <a href="moviereview.asp?ID=<%= rs("ID") %>">more</a></p>

<%
rs.Close
conn.close
set rs=nothing
set conn=nothing
%>


Nikkol
Forum Moderator

USA
6907 Posts

Posted - 28 February 2002 :  16:08:16  Show Profile
Check out this discussion:

http://forum.snitz.com/forum/topic.asp?TOPIC_ID=23313

(The latter part discusses what you want.)

Nikkol
Go to Top of Page

GauravBhabu
Advanced Member

4288 Posts

Posted - 28 February 2002 :  17:55:27  Show Profile
 

<%= left(rs("review"),100) %> <a href="moviereview.asp?ID=<%= rs("ID") %>">more</a></p>



www.forumSquare.com - GauravBhabu - It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying.
Go to Top of Page

skyhawks
Junior Member

USA
125 Posts

Posted - 28 February 2002 :  18:18:55  Show Profile  Visit skyhawks's Homepage
Thanks Gaurav... after reading what Nikkio told me, I got it to works. thanks ppl.

Go to Top of Page

skyhawks
Junior Member

USA
125 Posts

Posted - 01 March 2002 :  15:39:25  Show Profile  Visit skyhawks's Homepage
after going the method, i realized i shouldnt do that. just getting x amount of character to display would result in cutting a word short. so I've decide to display the first sentence... that would mean I would need to look for the "." (period). this is what I wrote.. but nothing comes out.

<%= Left(rs("review"), Instr(1, rs("review"), ".")) %>

I cant remember what I wrote, my result did display a number. which was the location of the period of characters.

any help would be deeply appreciated.

sky




Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 01 March 2002 :  17:23:05  Show Profile
What does the output look like when you just print rs("review")?

Nikkol
Go to Top of Page

GauravBhabu
Advanced Member

4288 Posts

Posted - 01 March 2002 :  17:40:12  Show Profile
Try this

<%= Left(rs("review"), Instr(100, rs("review"), ".",1)) %>

See Demo here


www.forumSquare.com - GauravBhabu - It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying.

Edited by - GauravBhabu on 01 March 2002 17:49:04
Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 01 March 2002 :  18:03:17  Show Profile
Ah, yes that last 1 means you're doing a text comparison (0 is default binary comparison). But should that matter if we're looking for a period?

Nikkol

Edited by - Nikkol on 01 March 2002 18:06:28
Go to Top of Page

skyhawks
Junior Member

USA
125 Posts

Posted - 02 March 2002 :  11:06:59  Show Profile  Visit skyhawks's Homepage
i'm still not getting anything to be display... this is how my code looks

jlo


<html><head><title></title></head><body>
<%
dim conn, rs, recCount, rec

set conn=server.CreateObject("adodb.connection")
set rs=server.CreateObject("adodb.recordset")
conn.Open "nydb"
strsql = "Select ID FROM movie"
rs.Open strsql, conn, 3
recCount = rs.RecordCount

rs.close
conn.Close
set rs=nothing
set conn=nothing

randomize
rec = int(rnd * recCount)

set conn=server.CreateObject("adodb.connection")
conn.open "nydb"
strsql = "Select ID, imgposter, movietitle, review FROM movie"
set rs=conn.execute(strsql)

rs.MoveFirst
rs.Move rec
%>

<p><img src="/posters/<%= rs("imgposter") %>" border=0>
<b><%= rs("movietitle") %></b><br>
<%= Left(rs("review"), Instr(100, rs("review"), ".", 1)) %>
<a href="/moviereview.asp?ID=<%= rs("ID") %>">more</a></p>

<%
rs.Close
conn.close
set rs=nothing
set conn=nothing
%>

</body></html>

Go to Top of Page

GauravBhabu
Advanced Member

4288 Posts

Posted - 02 March 2002 :  11:20:47  Show Profile
What you get when you use just this

<%= rs("review")%>


www.forumSquare.com - GauravBhabu - It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying.
Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 02 March 2002 :  11:23:36  Show Profile
Do you get output for the picture and movie title?

Nikkol
Go to Top of Page

skyhawks
Junior Member

USA
125 Posts

Posted - 02 March 2002 :  12:07:36  Show Profile  Visit skyhawks's Homepage
GauravBhabu,

when I write <%= rs("review") %> I will get all the data (TEXT) in that field.


Nikkol,

Yes, the poster and the movietitle do get displayed as well.


this is the html source code when i run that asp page.

<html><head><title></title></head>
<body>
<p><img src="/posters/crossroads_poster_small.jpg" border=0><br>
<b>Crossroads </b><br>

<a href="/moviereview.asp?ID=1">more</a></p>
</body></html>


Go to Top of Page

GauravBhabu
Advanced Member

4288 Posts

Posted - 02 March 2002 :  12:20:28  Show Profile
Try this

 
<%=Mid(rs("review"),1,instr(20,rs("review"),".",1))%>


www.forumSquare.com - GauravBhabu - It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying.
Go to Top of Page

skyhawks
Junior Member

USA
125 Posts

Posted - 02 March 2002 :  12:42:41  Show Profile  Visit skyhawks's Homepage
nope.. same thing.

Go to Top of Page

GauravBhabu
Advanced Member

4288 Posts

Posted - 02 March 2002 :  12:49:19  Show Profile
Try these

<%=Left(rs("review"),100)%> 


<%=Mid(rs("review"),1,100)%>


www.forumSquare.com - GauravBhabu - It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying.
Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 02 March 2002 :  13:12:13  Show Profile
Maybe this will help...

InStr([start, ]string1, string2[, compare])

Return Values
The InStr function returns the following values:

If InStr returns
string1 is zero-length 0
string1 is Null Null
string2 is zero-length start
string2 is Null Null
string2 is not found 0
string2 is found within string1 Position at which match is found
start > Len(string2) 0


That's from Microsoft ... i think the last one should be start>Len(string1)
Nikkol

Edited by - Nikkol on 02 March 2002 13:19:07
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Next Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.29 seconds. Powered By: Snitz Forums 2000 Version 3.4.07