If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Truncated SQL string

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-27-04, 18:54
roberte_3 roberte_3 is offline
Registered User
 
Join Date: Feb 2004
Posts: 1
Truncated SQL string

I have written VBA code to be executed from Excel macro to go out and connect to a remote database and fill a spread sheet with the data returned by the query.

The following code works if my rs.Open string is less than 255 characters but fails when the sql string is longer than 255 characters.
Do anyone know of a work around or an alternative approach?

Dim db As Connection
Set db = New Connection

db.CursorLocation = adUseClient
db.Open "DB2", "userid", "password"
Set rs = New Recordset

rs.Open "SELECT * from sometable ", db

Dim myRow
Dim myColumn

myRow = 1
myColumn = 1

Do Until rs.EOF
For Each fld In rs.Fields
Worksheets("Sheet1").Cells(myRow, myColumn).Value = fld.Value
myColumn = myColumn + 1
Next fld

myRow = myRow + 1
myColumn = 1
rs.MoveNext
Loop
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On