<%@ Language="VBSCRIPT" %> <% Dim DB_Path psw =0 Set Conn = Server.CreateObject("ADODB.Connection") DB_Path = Request.ServerVariables("APPL_PHYSICAL_PATH") & "fpdb/famchat.mdb" conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DB_Path & ";" ' i named my DSN with chatdb, you can use any, but don't forget to change it here too Set rs = Server.CreateObject("ADODB.Recordset") ' create the record set SQLStmt = "SELECT * FROM chatmain" ' select everything from the chatmain table rs.Open SQLstmt,Conn,1,2 rs.close Set FileStreamObject = CreateObject("Scripting.FileSystemObject") ' this is how you create the scripting object Set writeStream = FileStreamObject.CreateTextFile(Server.MapPath("top.htm"), True) ' here you set the name of the file that will be created Set rs2 = Server.CreateObject("ADODB.Recordset") ' i've opened a new recordset because I had some problems with the other rs SQLStmt = "SELECT * FROM chatmain ORDER BY id DESC" rs2.Open SQLstmt,Conn,1,2 writeStream.WriteLine "" ' this is the command that writes to the file writeStream.WriteLine "" ' as you see i am creating an html file writeStream.WriteLine "" ' this is the refresh that will ensure that the file is updated to the user of the chat writeStream.WriteLine "" writeStream.WriteLine "" writeStream.WriteLine "" writeStream.WriteLine "" writeStream.WriteLine "
" writeStream.WriteLine "" writeStream.WriteLine "" writeStream.WriteLine "" writeStream.WriteLine "" writeStream.WriteLine "
" writeStream.WriteLine "" & Application("ActiveUsers") & "Elrick Family Chat WebPage
" count = 0 ' I use this counter to ensure that won't be no more than 60 messages at the same time Do while not rs2.eof and count < 200 ' like I said the control of the messages, and the control of the end of the data ' here I will write the data that was written in the DB, so everyone that access ' to the top.htm will see the messages, simulating a real chat program writeStream.WriteLine "" writeStream.WriteLine "" writeStream.WriteLine "" writeStream.WriteLine "" writeStream.WriteLine "" count = count + 1 rs2.movenext loop writeStream.WriteLine "
 " & rs2("data") & " " & rs2("nick") & " " & rs2("message") & "
" writeStream.WriteLine "
" writeStream.WriteLine "
" writeStream.WriteLine "

" writeStream.WriteLine "" writeStream.WriteLine "" WriteStream.Close ' USE THE SAME CLOSE METHOD TO ALL THE OBJECTS THAT YOU USE rs2.Close %>

 

Loading Chat .....