Click to See Complete Forum and Search --> : Like this using MSAccess database


lebronletchev
02-14-2007, 04:30 AM
Dear friends,

I have a database with 3 fields: thestring, str_start and str_finish. I wm trying
display all results like below, but I am not able to do this!



thestring="She was driving and drinking at the same time."
str_start="driving"
str_finish="driking"
response.write StringBreaker(thestring,str_start,str_finish) & "<br>"

Thank you for any suggestion

Lebron

lmf232s
02-14-2007, 09:05 AM
have you connected to the database and retrived the values yet?


sSQL = "SELECT & FROM TALBE"
ors1 = oConn.Execute(sSQL)
If Not ors1.EOF Then
thestring = ors1("thestring")
str_start = ors1("str_Start")
str_finish = ors1("str_Finish")

response.write StringBreaker(thestring,str_start,str_finish) & "<br>"
End If

lebronletchev
02-14-2007, 01:14 PM
Yes. The problem is I want ouput a "substring" concateneting the
str_start + middle + str_finnish.

Problems:

1. When working with database it did not a "substring" like I want
2. It cut off not the str_finnish. It leaves de rest of string toghether (what if wrong).

OBS: I was testing your script, but it accuses an error in If .. then statement

Thank you again

LeBron Letchev

russell
02-14-2007, 01:40 PM
substring and concatenate are pretty much opposites, so, not sure what u are trying to do.

what do u want the output to look like? what does your StringBreaker() function do?

access (and asp) expect u to use the Mid() function, not Substring() function

lebronletchev
02-14-2007, 02:36 PM
Ok. I will give an good example I an want to do.

INPUT
=====

FIELDS (Tablex)

thestring str_start str-finish

Volvo New Trucks, SUVs Buy, sale Volvo Trucks
Volvo ... More Volkswagen cars Volkswagen Jersey
in New Jersey. Purchase BMW BMW Oklahoma
cars in Oklahoma.

Security crackdown launches in crackdown Baghdad
Baghdad

Chrysler announces 13,000 U.S. job announces job
cuts

You’ve heard of Netflix, now try us heard Netfix
for free.



OUTPUT
======


Volvo New Trucks
Volkswagen cars in New Jersey
BMW cars in Oklahoma
crackdown launches in Baghdad
announces 13,000 U.S. job
heard of Netfix

==========================

I know you Will say " And when there are two similar words, like "cars" or "the" in the same string? WELL, this forum is a free helpful, bot a pay service! So, this feature we leave for the next future.

Thansk you again

Lebron Letchev

lebronletchev
02-15-2007, 10:02 AM
Well, T hink I found a simple solution - not a solution made by a programmer - for my question:

x1= InStr(ors1("texts1"),ors1("str_start"))
x2= InStrRev(ors1("texts1"),ors1("str_finish"))
x3=Mid(ors1("texts1"),x1,(x2-x1)+len(ors1("str_finish")))


response.write "<font color='red'><b>" & x3 & "</b></font>" & "<br>"

At least works!

Thank you

LebronLetchev