Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Asp problem cant se what missed

Status
Not open for further replies.

mailerman

Technical User
Jan 2, 2007
29
0
0
SE
hey there, i did this code to retrive 10 MMS pictures from my mysql database and /data folder and put them in a table onto my page, now i missed someting here since it donw work but i cant se what, anyone got an idea on what i missed?

<%
// Definiera konstanter för databasanslutning
Dim FSO, Row, MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE

MYSQL_HOST = "aaa"
MYSQL_USER = "aaa"
MYSQL_PASSWORD = "aaa"
MYSQL_DATABASE = "aaa"

Set FSO = Server.CreateObject("Scripting.FileSystemObject")

// Anslut till databasen
Set Conn = Server.CreateObject("ADODB.Connection")
//Inte säker på kopplingssträngen, inte mitt gebit, men något såhär
Conn.Open "Provider=sqloledb;" & _
"Data Source="&MYSQL_HOST&";" & _
"Network Library=DBMSSOCN;" & _
"Initial Catalog="&MYSQL_DATABASE&";" & _
"User ID="&MYSQL_USER&";" & _
"Password="& MYSQL_PASSWORD&";"

// Plocka ut 10 senaste MMS
Set RS = Conn.Execute("SELECT *,unix_timestamp(tstamp) as utstamp FROM mms ORDER BY tstamp DESC LIMIT 10")

// Eka ut en tabell
Response.Write "<table cellspacing=""2"" cellpadding=""5"" border=""2""><tr>"

// Gå igenom varje MMS - skriv ut tabellrader
Do While Not RS.EOF
// Plocka bort första ordet (prefix) ur meddelandet
//Denna förstår jag mig inte riktigt på. Då PHP-koden jobbar direkt mot recordset:et. Men jag förstår inte syftet.
Row = Left(RS("Message") ,InStr(RS("Message")," "))

// Plocka ev bort andra ordet ur meddelandet, på samma sätt
// $row['message'] = substr($row['message'],strpos($row['message'],' '))

// Läs in eventuell bild från mappen 'data'
if FSO.FileExists(Server.Mappath("data/" & RS("ID") & ".jpeg") then
Picture = "data/" & RS("ID") & ".jpeg"
else
Picture = ""
end if

if Picture <> "" Then
Response.Write "<a href=""visabild.asp?id=" & RS("ID") & """>"
Response.Write "<img width=""150"" src=""" & Picture & """></a>"
end if

Response.Write "</td></tr></table>"
%>
 

Your Do While loop needs a Movenext and a Loop. At the end of your code (instead of your Response.Write "</td></tr></table>"):
Code:
Response.Write "</td>"
FSO.Movenext
Loop
Response.write "</tr></table>"

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
i changed it, then this appeared :/

Code:
Microsoft VBScript compilation  error '800a03ee'

Expected ')'

/mms/mms.asp, line 38

if FSO.FileExists(Server.Mappath("data/" & RS("ID") & ".jpeg") then
---------------------------------------------------------------^
 
mailerman, I think johnwm meant
Code:
Response.Write "</td>"
[COLOR=red]RS.Movenext[/color]
Loop
Response.write "</tr></table>"

George
 
Thanks George - sloppy reading on my part!

Mailerman - you have 3 ( and only 2 )

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
now i got

Code:
Microsoft OLE DB Provider for SQL Server error '80004005'

[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.

/mms/mms.asp, line 15

i dont belive it's any settings, password host or login that is wrong, i matched to the written settings on my providers setting page and it's all correct.
 
Suggest you use one of the standard references to sort out your connection string:

Then read faq222-2244 (as noted at the bottom of my first post) to learn about basic research and how the forum works.

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top