Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
| Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 6th, 2007, 04:00 PM
Authorized User
Points: 457, Level: 7
Points: 457, Level: 7 Points: 457, Level: 7 Points: 457, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2004
Location: Burbank, CA, USA.
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Arsi
Default Run-time '-2147467259 (80004005)'

Hello,

I'm getting a run-time error:
Run-time '-2147467259 (80004005)': [Micorosoft][ODBC Driver Manager] Data source name too long

What is the problem exactly and how can I resolve it?

This is my code:

Sub CSV()
Dim sPath As String
Dim sFileName As String

sPath = CurDir
sFileName = "sample.csv"

Dim sConn As ADODB.Connection
Set sConn = New ADODB.Connection
Dim rsData As ADODB.Recordset
Dim sSQL As String

Dim qtData As QueryTable
Dim wbSheet As Workbook
Dim wDataSheet As Worksheet
Dim rnStart As Range
Dim stADO As String

stADO = "ODBC;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sPath & ";Extended Properites=Text;"

Set wDataSheet = Worksheets("Data")
wDataSheet.Activate
wDataSheet.Unprotect

With wDataSheet
    Set rnStart = .Range("A1")
End With

sSQL = "SELECT * FROM " & sFileName & " WHERE CompCode = 9"

Set sConn = New ADODB.Connection

With sConn
    .CursorLocation = adUseClient
    .Open (stADO)
    .CommandTimeout = 0
    Set rsData = .Execute(sSQL)
End With

Set qtData = wDataSheet.QueryTables.Add(rsDatam, rnStart)

qtData.Refresh

rsData.Close
sConn.Close
Set rsData = Nothing
Set sConn = Nothing
End Sub

sPath = W:\Folder1\Folder2\Folder3\Folder4\Folder5

W is a mapped drive to a server.

Thanks for the help in advance.





*******(*)*******
__________________
*******(*)*******


Similar Threads
Thread Thread Starter Forum Replies Last Post
runtime error '-2147467259 (80004005) sonal Excel VBA 0 August 13th, 2007 07:06 AM
runtime error '-2147467259(80004005) denkidude Visual Basic 2005 Basics 1 March 16th, 2007 06:34 AM
Design-Time or Run-Time now ? ALGNET .NET Framework 2.0 1 July 31st, 2006 04:43 AM
run time error -2147467259(80004005) JohnRS4 Pro VB 6 1 June 12th, 2006 01:44 PM
run-time error -2147467259 (80004005) paul20091968 Excel VBA 0 May 11th, 2006 01:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.