Results 1 to 5 of 5

Thread: asp connection by using fixed path ??

  1. #1

    Thread Starter
    Hyperactive Member xray's Avatar
    Join Date
    Jun 2003
    Location
    EgYpT
    Posts
    312

    Unhappy asp connection by using fixed path ??

    peace be with you

    i made a web page using "asp" but i want it to work in a fixed " ip & path " i using this code for this connection :::

    Code:
    dim db,db_path
    set db = server.createobject("adodb.connection")
    'db_path=server.mappath("db/sealab.mdb")
    db_path= "\\192.168.0.62\db\sealab.mdb"
    db.open "provider=microsoft.jet.oledb.4.0;data source="+db_path
    but when i test it an error raise ::

    Code:
    Error Type:
    Microsoft JET Database Engine (0x80004005)
    The Microsoft Jet database engine cannot open the file '\\192.168.0.62\db\sealab.mdb'. It is already opened exclusively by another user, or you need permission to view its data.
    /book3/conn.asp, line 16
    how i can make the connection work with this case to make the " asp page" read data from fixed " ip " and path .
    note :
    the folder " db " is sharing .... read only

    thanks
    In the name of allah , the beneficent , the merciful

    Say (O Muhammad ): We believe in allah and that which is revealed unto us and that which was revealed unto abraham and ishmael and isaac and jacob and the tribes , and that which was vouchsafed unto moses and jesus and the prophets from their lord . we make no distinction between any of them , and unto him we have surrendered


    ---- Great Sites For You -------------------

    If you want to know some small things about islam ?

  2. #2
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: asp connection by using fixed path ??

    If the DB file is located on another server, you will have to download it first, save it on your server, then open it up. This is actually easy.

    If it is located on your server, then you could just get the URL path .. even better .. Server.Mappath("./MyFolder/MyFile.mdb")

    here is an ASP page I just knocked together that downloads a remote file, saves it to the server (i used a folder called _tmp in this example), and also gets the Response Header of the request, meaning if the page is not found or the page has an error in it for some reason it will show an error .. if not it will show it was downloaded .. that is the part where you would then open the file and do what you want to it ..

    Files are saved with the prefix "tmp' and then the time and date and the file extension .. in this case ".mdb"

    Change the Constants at the top to your own settings.

    Rory

    Code:
    <%@ Language="VBScript" %> 
    <%
    Option Explicit
    
    '// SET RESPONSE HEADERS
    Response.Buffer = True
    Response.Expires = 0
    Response.ExpiresAbsolute = Now() - 1
    Response.AddHeader "cache-control","private"
    Response.AddHeader "pragma", "no-cache"
    
    '// 5 MINUTE TIMEOUT
    Server.ScriptTimeout = 300
    
    Dim strFile
    Dim strText
    Dim strStatus
    Dim strResults
    
    '// FILE TO DOWNLOAD
    Const strSource = "http://www.myurl.com/database/mydb.mdb"
    
    '// FOLDER TO SAVE TO (set permissons on this!!)
    Const strFolder = "_tmp"	
    
    '// RESPONSE TURNED ON
    Const blnResponse = True
    
    
    '// SUB TO DOWNLOAD FILE
    Sub DownloadFile(byRef strTemp)
    
    	Dim strDate, strTime
    	Dim objHttp, objStream
    	
    	Const adTypeBinary = 1
    	Const adSaveCreateOverWrite = 2
    
    	On Error Resume Next
    
    	'// CREATES TEMPORARY FILE
    	strDate = Day(Date) & Month(Date) & Year(Date)
    	strTime = Hour(Time) & Minute(Time) & Second(Time)
    	strTemp = Trim(replace("tmp" & strTime & strDate & ".mdb"," ",""))
    	strTemp = Server.Mappath("./" & strFolder & "/" & strTemp)
    
    	'// SHOW RESPONSE
    	If CBool(blnResponse) Then
    		Response.Write "<b>Downloading Remote File.</b>  " & vbCrLf
    		Response.Write "Please Wait .." & vbCrLf
    		Response.Flush
    	End If
    	
    	'// DOWNLOAD THE PAGE
    	Set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
    	objHttp.Open "GET", strSource, False
    	objHttp.Send ""
    	strStatus = objHttp.Status
    	strResults = objHttp.StatusText
    	
    	'// SAVE TO LOCAL SERVER
    	Set objStream = Server.Createobject("Adodb.Stream")
    	objStream.Type = adTypeBinary
    	objStream.Open
    	objStream.Write objHttp.ResponseBody
    	objStream.Savetofile strTemp, adSaveCreateOverWrite
    	objStream.Close
    
    	'// CLOSE OBJECTS
    	Set objStream = Nothing
    	Set objHttp = Nothing
    	
    	'// SHOW ERROR & END
    	If err <> 0 Then
    		Response.Write "<br><font color=""red""><b>Error " & Err.Number & ".</b>  " & vbCrLf
    		Response.Write Err.Description & "</font>" & vbCrLf
    		Response.End
    	End If
    
    End Sub
    
    '// DOWNLOAD NOW
    Call DownloadFile(strFile)
    
    '// IF RESPONSE ERROR
    If strStatus >= 400 And strStatus <= 599 Then
    	Response.Write "<br><font color=""red""><b>Error " & strStatus & ".</b>  " & vbCrLf
    	Response.Write strResults & "</font>" & vbCrLf
    	Response.End
    Else
    '// ELSE OPEN FILE TO WORK ON
    	Response.Write "<br><b>Download Complete</b>" & vbCrLf
    End If
    %>
    Last edited by rory; Jun 10th, 2006 at 06:35 PM.

  3. #3
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: asp connection by using fixed path ??

    Another option is this ..

    If you can place an ASP page on the remote server ..

    Local Server Page ..

    xHttp.asp
    Code:
    <%@ Language="VBScript" %> 
    <%
    Option Explicit
    
    '// SET RESPONSE HEADERS
    Response.Buffer = True
    Response.Expires = 0
    Response.ExpiresAbsolute = Now() - 1
    Response.AddHeader "cache-control","private"
    Response.AddHeader "pragma", "no-cache"
    
    Dim objHttp
    Dim strText
    Dim strURL
    Dim strStatus
    Dim strResults
    
    strURL = "http://www.mywebsite.com/xHttpRec.asp?action=get&id=24"
    
    '// GET A REMOTE WEB PAGE
    Function RemoteData()
    	Dim strData
    	On Error Resume Next
    	Set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
    	objHttp.Open "GET", strURL, False
    	objHttp.setRequestHeader "Content-Type", "text/html"
    	If Err = 0 Then
    		objHttp.send
    		strStatus = objHttp.Status
    		strResults = objHttp.StatusText
    		strData = objHttp.ResponseText
    	End If
    	Set objHttp = Nothing
    	If Err <> 0 Then
    		strData = "Error " & Err.Number & "<br>" & _
    		Err.Description & vbCrLf
    	End If	
    	RemoteData = strData
    End Function
    
    '// GET PAGE NOW
    strText = RemoteData
    
    '// RESPONSE ERROR
    If strStatus >= 400 And strStatus <= 500 Then
    	Response.Write "Error " & strStatus & "<br>"
    	Response.Write strResults & vbCrLf
    	Response.End	
    '// SHOW DATA FROM PAGE
    Else
    	Response.Write strText
    End If
    
    %>

    Remote Page (Database Location)
    Very Simple Example.

    xHttpRec.asp
    Code:
    <% Response.Write "Okay" %>
    See this link for a more detailed example ..
    http://www.vbforums.com/showthread.p...70#post2477670
    Last edited by rory; Jun 10th, 2006 at 09:25 PM.

  4. #4

    Thread Starter
    Hyperactive Member xray's Avatar
    Join Date
    Jun 2003
    Location
    EgYpT
    Posts
    312

    Re: asp connection by using fixed path ??

    peace be with you

    thanks
    In the name of allah , the beneficent , the merciful

    Say (O Muhammad ): We believe in allah and that which is revealed unto us and that which was revealed unto abraham and ishmael and isaac and jacob and the tribes , and that which was vouchsafed unto moses and jesus and the prophets from their lord . we make no distinction between any of them , and unto him we have surrendered


    ---- Great Sites For You -------------------

    If you want to know some small things about islam ?

  5. #5
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: asp connection by using fixed path ??

    no problem, any questions let me know ..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width