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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

From SQL Server to client in MS-Access via ASP

Status
Not open for further replies.

zakman

Programmer
Aug 15, 2001
49
0
0
US
I have an ASP that massages data to send to the client's
browser by changing the ContentType and disposition of
the page so that Excel will auto-open on the client's
workstation to view the data as a CSV file.

This works fine, however, the client has been saving the
data, then opening an Access database & importing the data.
The client would like to request the data on the site and
have the data return in the form of an Access database,
ready to open on the client's workstation.

Either this cannot be done OR I'm missing something...

rsTest.Open "SELECT ...", conDB, adOpenForwardOnly, adLockReadOnly
Response.Clear
Response.AddHeader "Content-disposition", "attachment;filename=Test.MDB"
Response.ContentType = "application/vnd.ms-access"
Response.flush

Response.BinaryWrite rsTest.getString
rsTest.close

' This looks good on the screen, but it doesn't return the
' proper binary format of an Access database, thus the client
' Access program doesn't recognize the mdb structure & fails.

--KevinZ



--Kevin
 
Kevin, you might have the right idea but you need to send the entire MDB file not a resultset object from a query of the database file, they are not the same thing. You could just place a link to the file on the page and the browser might do the rest, i don't know without trying so i'll leave that to you.

-pete
 
Ah yes, I realized that after I submitted the question...

I suppose my question now could be divided into two parts:

1. Can you create an access database container within ASP and
stuff your recordset (from SQL) into it. I can't use ODBC
within access database as the user can't hit SQL Server.

2. How can you deliver the Access MDB to the client via ASP?
Having the client's browser open it in MS Access...



--Kevin
 
I'm close to answering my own #2...

Set objStream = Server.CreateObject("ADODB.Stream")

objStream.Type = 1 ' binary
objStream.Open

objStream.LoadFromFile fname

Response.clear
Response.AddHeader "Content-Disposition", "attachment;filename=Test.MDB"
Response.ContentType = "application/vnd.ms-access"
Response.flush

Response.BinaryWrite objStream.Read
Response.Flush

objStream.Close
Set objStream = Nothing

---------
I am unclear about "vnd.ms-access" above...

Also, this seems to work, however, the client's browser is blank,
and if you view the source, it appears to be the actual binary
source of the database... funky!



--Kevin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top