Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server ASP
|
SQL Server ASP Discussions about ASP programming with Microsoft's SQL Server. For more ASP forums, see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server ASP 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
 
Old September 18th, 2006, 02:21 PM
Authorized User
 
Join Date: Jun 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default CopyFromRecordset Error

While pulling data from MS SQL and dumping it to a worksheet using the following code. It has worked until the (description field) exceeds 911 char. My question is is there indeed a 911 char limit. zConnectionString = _
"Provider=SQLOLEDB.1;Password=xxxxxx;Persist Security Info=True;" + _
"User ID=xxxxxx;Initial Catalog=xxxxxxxx;Data Source=xxxxxxxx;"

    zSQL = "select DISTINCT ProcBusCycle,CntrlName,ActnPlanName,ActnPlanDocTit le,ActnPlanDesc,ActnPlanCriticality,ActnPlanSteps, ActnPlanStatus,ActnPlanDueDate,ActnPlanResponse,Cn trlDesc,CntrlFrequency,CntrlType2 from ObjSrchTypViewActPlnProcRskMatCntrls Where OrgUnitName LIKE '%Intel%'AND ProcBusCycle NOT LIKE ('%Information%')"
    Set zConnection = New ADODB.Connection
    zConnection.ConnectionString = zConnectionString
    zConnection.Open
    Set zRecordset = New ADODB.Recordset
    zRecordset.CursorLocation = CursorLocationEnum.adUseClient
    zRecordset.CursorType = CursorTypeEnum.adOpenStatic
    zRecordset.LockType = LockTypeEnum.adLockBatchOptimistic
    Call zRecordset.Open(zSQL, zConnection, , , CommandTypeEnum.adCmdText)
   Call Sheet4.Range("A2").CopyFromRecordset(zRecordset)
   Set zRecordset.ActiveConnection = Nothing
   Set zConnection = Nothing

 
Old April 17th, 2007, 10:26 AM
Registered User
 
Join Date: Apr 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have seen the exact same limitation when using the CopyFromRecordset method. 911 characters is OK, but 912 breaks.

I have been able to get around this problem by checking the string length and just truncating strings down to the correct size. That works well and doesn't slow you down too much.

Another thing that I have been able to get to work is to loop through the recordset one row at a time, and copy the data into each cell individually. This allows you to paste large strings into the cell, but it's not perfect either. Only the first 1000 characters (approximately) will be visible in the spreadsheet. All data is present in the cell as expected (when viewed in the formula bar), but not all characters are shown (even if the size of the cell/row is expanded manually) and only a certain amount (also about 1000 characters) appears in the printed form.

Sorry I can't help more, but I hope you can use what I've done to come up with a work-around.






Similar Threads
Thread Thread Starter Forum Replies Last Post
runtime error when copyfromrecordset wuy Excel VBA 0 October 11th, 2007 09:16 PM
Copyfromrecordset error using ADO maaron Excel VBA 0 August 11th, 2006 08:52 AM
copyFromRecordset error Excel macro maaron SQL Server ASP 0 August 11th, 2006 08:44 AM
CopyFromRecordset and ADO.NextRecord chrislepingwell Excel VBA 3 March 28th, 2005 11:50 AM
CopyFromRecordset to Spreadsheet rweide SQL Server ASP 2 October 14th, 2004 03:56 PM





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