Forum Moderators: open
Here's the code....
Asp Code:
--------------
Dim rs
set con=Server.CreateObject("ADODB.Connection")
con.Provider="Microsoft.Jet.OLEDB.4.0"
con.Open "C:\Database.mdb"
Set rs = Server.CreateObject ("ADODB.Recordset")
rs.Open "SELECT * FROM Sentence", con
SomeVar= "hi "
D1= rs("Column1")
response.write D1
--------------
The Access database cell rs("Column1") has the following content:
--------------
<%=SomeVar%> how <br><br> are you?
--------------
The desired output is:
--------------
hi how
are you?
--------------
The actual output is:
--------------
<%=SomeVar%> how
are you?
--------------
<%
dim strVar
'--- connect to DB and fill a recordset
strVar = rs("Column1")
'--- close DB
%>
<html>
<%=strVar%>, how are you?
</html>
So if Column1 in your DB contained "Matt", then you would have:
Matt, how are you?
If you want to have the rest of the greeting ("how <br><br> are you?") to be customized, you could also store that in the database and output as needed.
Dim rs
set con=Server.CreateObject("ADODB.Connection")
con.Provider="Microsoft.Jet.OLEDB.4.0"
con.Open "C:\Database.mdb"
Set rs = Server.CreateObject ("ADODB.Recordset")
rs.Open "SELECT * FROM Sentence", conSomeVar= "hi "
D1= rs("Column1")
Eval(cStr(D1))
However you can't use the Asp shortcut tags (<%=your code%>) in the database. you'll have tochange the content in column 1 to the following...
Response.write(SomeVar & "how <br><br> are you?")
The suggestion from MattGlet and MrMister is a working solution. However, I was trying to avoid that code order for this particular application.
I'd like to achieve the following functionality
Given: Database, Database_W, Column1, SomeVar
Where: Column1 = "hi <%=SomeVar%> how <br><br> are you?"
Another way to do this is to split up the paragraph and load SomeVar and the paragraph at the same time like this:
Response.Write rs(Column1) & " " & rs2(SomeVar) & " " & rs(Column2) & " ."</td></tr> But in a large paragraph with many variables this creates many divisions and awkward editing.
Is there a way to achieve the desired functionality?
Thank you!