Results 1 to 4 of 4

Thread: [RESOLVED] Permission denied

Threaded View

  1. #1

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Resolved [RESOLVED] Permission denied

    Hi All,
    I am using this method reading Excel .

    Code:
    Private Sub Command1_Click()
    Dim cn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
     Sql = "Select * from [Call Summary$] Where F2 Is Not Null And F3 Is Not Null and F4 Is Not Null "
            ConnectionString = GetDriverString("D:\NewSampleFile.xls", "xls")
            Set cn = New ADODB.Connection
                With cn
                    .ConnectionString = ConnectionString
                    .Open
                    If .State = 1 Then
                        Set rs = New ADODB.Recordset
                        cn.CursorLocation = adUseClient
                        rs.Open Sql, cn, adOpenDynamic, adLockOptimistic
                        rs.Close
                    End If
                End With
                cn.Close
                Set rs = Nothing
                
              Set cn = nothing
        Dim fso As New FileSystemObject
        fso.MoveFile "D:\NewSampleFile.xls", "d:\test\"
    End Sub
    Public Function GetDriverString(ByVal sFileName As String, ByVal Extension As String) As String
        Dim strProvider As String
        Select Case Extension
        
            Case "xls"
                strProvider = "Provider=MSDASQL;DSN=Excel Files;Uid=;Pwd=;Dbq=" & sFileName & ";"
                GetDriverString = strProvider
                    
            Case Else
                'Do nothing
            End Select
    
    End Function
    And during the Moving File I get the Permission denied Error. Any ideas ?
    Last edited by danasegarane; Jul 21st, 2009 at 10:38 AM.
    Please mark you thread resolved using the Thread Tools as shown

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