PDA

View Full Version : Getting Data From A Database


Thatguy2001au
10-15-2002, 12:29 PM
Sorry for all the questions guys!

What i want to know is, when i get data from a database field, can i only choose to get only part of that data, say the first 200 characters and display them in my web page instead of displaying the entire field???

eg: Instead of this -

This is a sample of what I am trying to do, pretend that this data has come from a database, this is showing the whole field.

Can I do something to get -

This is a sample of what I am trying to do, pretend that this data has come from...

Any help will be greatly appreciated!

karolmcauley
10-15-2002, 02:12 PM
Give the data that you are trying to retrieve a variable name eg.

getdata =("rs.fieldname")......this will be the entire field stored in getdata.

As far as i am aware you just have to ;

trim(left$("getdata", len("getdata")+200))

I may be wrong as i am simply a novice, but its very close.

Thatguy2001au
10-15-2002, 02:32 PM
Thanks

I tried what u gave me but it doesn't seem to work. Thanks for your help anyway.

karolmcauley
10-15-2002, 03:27 PM
Have u got all the database connection part worked out right?? Post it here?

Try

getdata = rsTemp("fieldname")......this will be the entire field stored in getdata.


trim(left$(getdata, 200)) ......this will retieve only the first 200 characters

i have tried it and this one works

webmarkart
10-15-2002, 03:28 PM
Try this once you have your select statment finished...

<%= Left(rs("yourvariable"),200) %>

Thatguy2001au
10-15-2002, 03:35 PM
Hi

Here is the code i am trying to change. I have not included any variables yet. AD_DESCRIPTION is the name of the field.
All of this is contained in a table along with other fields which gets repeated for the number of records that exisit.

<%=(rsAds.Fields.Item("AD_DESCRIPTION").Value))%>

How would i change this??? or how do i make the variable??

thanks.

karolmcauley
10-15-2002, 03:49 PM
what is it you want? The code to loop through each record and return it to the page or code to retrieve only the first 200 chars of the AD_Description field??

Thatguy2001au
10-15-2002, 03:50 PM
The code to get only the first 200 characters of that field.

karolmcauley
10-15-2002, 03:53 PM
<%= Left(rsAds("AD_DESCRITPION"),200) %>

Thatguy2001au
10-15-2002, 03:56 PM
Thanks alot man, you are a genius! it works perfectly.