Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » General

Post new topic   Reply to topic
Select a data from SQL server then put in HTML coding
View previous topic :: View next topic  
Author Message
calvinkwoo3000
Newbie


Joined: 08 Feb 2006
Posts: 11

PostPosted: Mar 15th, 2006 12:39 AM    Post subject: Select a data from SQL server then put in HTML coding Reply with quote

I have make an advertisement in my E-learning Project.

I make the advertiment using Adrotator.

How can i Select a Word from database like "Sport".

Then put in the HTML like

"<asp:adrotator id="Ad" AdvertisementFile="Sport.xml"></asp:adrotatorasasp:adrotator>"

so that i can make an advertiment depend on their hobby.

Thanks
Back to top
View user's profile Send private message
dougthomas
Moderator


Joined: 27 Jul 2005
Posts: 271
Location: Essex, UK

PostPosted: Mar 15th, 2006 01:11 AM    Post subject: Reply with quote

Hi,

A way to do this would be to:
(1) SELECT the information from the appropriate table
(2) Use the Replace function to substitute the result of the query into the html string
(3) Write the HTML string to a file

eg
Code:

Dim strHTML As String
Dim strHTML1 As String
Dim strSQL As String
Dim str34 As String
Dim strHobby As String
Dim intFile As Integer
str34 = Chr(34)
intFile = FreeFile
Open "c:\MyDir\MyFile.html" For Output As #intFile
strHTML = str34 & "AdvertisementFile=" & str34 & "XXXX.xml" & str34 & "></asp:adrotatorasasp:adrotator>" & str34
strSQL = "SELECT fldHobby FROM myTable WHERE fldUser = " & str34 & strName & str34
myRecordSet.Open strSQL, myConnection
If myRecordSet.Count <> 0 Then
    strHobby = myRecordSet![fldHobby]
    strHTML1 = Replace(strHTML, "XXXX", strHobby)
    Print #intFile, strHTML1
Else
    MsgBox "Hobby for" & strName & "Not Found"
End If

E&oE

Regards
Doug
_________________
If you can see the light at the end of the tunnel, it probably means there's a Train coming.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » General All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic