-
Hello Michelle,
This regarding the answer to my question.
Shall I explain my problem ?
This is an accounting s/w.I am using different databases.When the user creates a new company ,I am creating a new database and storing that path in a table which is in master database.
I made the whole c drive sharing.But my question is, when I run the package I am opening the connection by selecting the corresponding path stored in the database.
Another system on a n/w,how it will accept the path "c:\fbfjf" ?
Hope you got me now.
-
I assume you are reffering to 'Mapped' network drives on other PCs looking at your Shared C:\?
Then use a UNC path name:
The following gives an example:
Code:
' These represent the possible returns errors from API.
Public Const ERROR_BAD_DEVICE As Long = 1200
Public Const ERROR_CONNECTION_UNAVAIL As Long = 1201
Public Const ERROR_EXTENDED_ERROR As Long = 1208
Public Const ERROR_MORE_DATA As Long = 234
Public Const ERROR_NOT_SUPPORTED As Long = 50
Public Const ERROR_NO_NET_OR_BAD_PATH As Long = 1203
Public Const ERROR_NO_NETWORK As Long = 1222
Public Const ERROR_NOT_CONNECTED As Long = 2250
Public Const NO_ERROR As Long = 0
' This API declaration is used to return the
' UNC path from a drive letter.
Declare Function WNetGetConnection Lib "mpr.dll" Alias _
"WNetGetConnectionA" _
(ByVal lpszLocalName As String, _
ByVal lpszRemoteName As String, _
cbRemoteName As Long) As Long
Function F_GetUNCPath( _
ByVal strDriveLetter As String, _
ByRef strUNCPath As String _
) As Long
On Local Error GoTo GetUNCPath_Err
Dim Msg As String
Dim lngReturn As Long
Dim strLocalName As String
Dim strRemoteName As String
Dim lngRemoteName As Long
strLocalName = strDriveLetter
strRemoteName = String$(255, Chr$(32))
lngRemoteName = Len(strRemoteName)
lngReturn = WNetGetConnection( _
strLocalName, _
strRemoteName, _
lngRemoteName _
)
If lngReturn = NO_ERROR Then
'// Return the UNC through the function.
F_GetUNCPath = NO_ERROR
strUNCPath = Trim$(strRemoteName)
strUNCPath = Left$(strUNCPath, Len(strUNCPath) - 1)
Else
'// Return the original driveletter & error.
F_GetUNCPath = lngReturn
strUNCPath = strDriveLetter & "\"
End If
GetUNCPath_End:
Exit Function
GetUNCPath_Err:
F_GetUNCPath = ERROR_NOT_SUPPORTED
strUNCPath = strDriveLetter
Resume GetUNCPath_End
End Function
Call with the following:
Code:
Dim strUNC As String
If F_GetUNCPath("C:", strUNC) = NO_ERROR Then
strPath = strUNC & "fbfjf"
Else
strPath = "C:\fbfjf"
End If
:cool: