-
conn.open problem
I'm stuggling with this problem waaaaay to long...
i want to generate a letter when a button is clicked on my page. Ms Word should be opened and you should be able to see the document filling up as the code executes...
this is the script i wrote:
Code:
<script language="vbscript">
dim objword
Sub OpenDoc()
dim Objword
dim rs, conn, Sql, Rs2, Sql2, Nummer
set Conn = createobject("ADODB.Connection")
set Rs = createobject("ADODB.Recordset")
set Rs2 = createobject("ADODB.Recordset")
set objword = createobject("Word.application")
objword.visible = true
objword.documents.add "C:\Diensthoofd_hartrev.dot"
objdoc = objword.activedocument
'
conn.Open "DSN=TAFTEN;UID=Administrator;PWD=test"
'Sql = "Select * from onderzoeken where onderzoeksnummer = '040607-3EF'"
'rs.Source = sql
'rs.ActiveConnection = conn
'rs.Open
'objword.selection.typeparagraph
'objword.selection.typetext chr(9) & chr(9) & chr(9) & chr(9) & chr(9) & chr(9) & chr(9)& chr(9) & chr(9) & "Aan Prof. Dr. Seppen"
'objword.selection.typeparagraph
'objword.selection.typetext chr(9) & chr(9) & chr(9) & chr(9) & chr(9) & chr(9) & chr(9)& chr(9) & chr(9) & "Cardiologie"
'objword.selection.typeparagraph
'objword.selection.typetext chr(9) & chr(9) & chr(9) & chr(9) & chr(9) & chr(9) & chr(9)& chr(9) & chr(9) & "Alhier De joskens 185"
'objword.selection.typeparagraph
'objword.selection.typetext chr(9) & chr(9) & chr(9) & chr(9) & chr(9) & chr(9) & chr(9)& chr(9) & chr(9) & "9000 Gavere"
'objword.selection.typeparagraph
'objword.selection.typeparagraph
'objword.selection.typetext chr(9) & chr(9) & chr(9) & chr(9) & chr(9) & chr(9) & chr(9)& chr(9) & chr(9) & "Gavere, 16 juli 2004"
'objword.selection.typeparagraph
'objword.selection.typeparagraph
'objword.selection.typetext "Geachte Collega,"
on the server this worked perfectly... but when i requested the page from a client-machine on the same domain and clicked the button, a worddocument was opened but further nothing happened. on the bottom of my page a yellow !-sign tells me '"error on page", nothing more... by putting the rest of my code between ' i know that the error is in the line: "conn.Open "DSN=TAFTEN;UID=Administrator;PWD=test""
please help me, i'm getting desperate...
-
Hello,
Instead of using dsn connection, try mapping to the db on your webserver. Sample code is;
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../lpathname") & "\dbname.mdb")
you can substitute the type of drivers you are using if not MS Access by using the same drivers as listed in the dsn for that type of db.
I cannot see any errors with the syntax you are using for your connection, but just check the dsn name, UID and Password to ensure they are----- "TAFTEN;Administrator;test"
Cheers
-
Thank you for your reply!!! I was getting the idea that the client could use the system-dsn on my server to acces my (SQL) database... Off course that didn't work! :blush:
So i made a system dsn on the client machine and everything works fine know... I think i would've realized this a lot sooner if internet explorer would give me a detailled error message rather then "error on page"... maybe that's an excuse for me...
thanks again for your time!
greets,