Friday, July 31, 2009

How can I define the connection String for ASP to connect MS Excel?

Make an ODBC of the MS Excel file and your connection string will be like :-





ConnString = "DSN=myDsn;Uid=username;Pwd=;"





Or there is another way of doing it directly:-





ConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyExcel.xls;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"""

How can I define the connection String for ASP to connect MS Excel?
You could try creating an ODBC DSN for your Excel document, and then using a standard ODBC connection string for that DSN, as though you were connecting to any other ODBC source.
Reply:LINE 1 =%26gt;set cn = server.createobject("adodb.connection")





LINE 2 =%26gt;cn.open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" %26amp; Server.Mappath("mydb.mdb") %26amp; ""





LINE 3 =%26gt;cn.execute("SELECT * FROM table")


No comments:

Post a Comment