Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server DTS
| Search | Today's Posts | Mark Forums Read
SQL Server DTS Discussion specific to Data Transformation Service with SQL Server. General SQL Server discussions should use the general SQL Server forum. Readers of the book Professional SQL Server 2000 DTS with questions specific to that book should post in that book forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server DTS 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 September 8th, 2005, 11:03 AM
sjm sjm is offline
Registered User
 
Join Date: Aug 2005
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Cannot display/return SQL Query Output from a Vari



I have been having a very difficult time trying to get the output of a sql query that is in a DTS global variable to return, presently to a messagebox.

I created an Execute SQL task with the query I wish to use. The query has been tested in Query Analyzer and works fine and returns the results I am looking for. I set a global variable to the result set. Basically, I wish to display the results as a string or similar in a messagebox.

I have created the Execute SQL task as described in http://msdn.microsoft.com/library/en..._task_4gkl.asp .

I have tried to retrieve the results using the example in
http://msdn.microsoft.com/library/de..._task_6llt.asp but I have been unable to do so.

I also tried the GetString method of the recordset without success.

I also tried the using the “Storing the resultset in a flat file” example from http://dotnetbips.com/displayarticle.aspx?id=228 and I was unable to write the recordset to a file.

What is the proper way to display a variable of type dispatch? I feel like I am going about this the wrong way.

I welcome suggestions and comments on how to achieve the goal of displaying the query results.

Thanks.




  #2 (permalink)  
Old September 9th, 2005, 11:40 AM
sjm sjm is offline
Registered User
 
Join Date: Aug 2005
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Everything is fine with the code listed below. I am going to use this
instead of the DTS execute sql task.


Option Explicit


Function Main()


dim cnn
dim rs
dim intLoop
dim strText


set cnn=createobject("ADODB.Connec­tion")


cnn.Open "Provider=sqloledb;" & _
           "Data Source=SERVER;" & _
           "Initial Catalog=msdb;" & _
           "Integrated Security=SSPI"


set rs=cnn.execute("SQL QUERY")


If rs.BOF then


msgbox "No Records Found"


else


do until rs.EOF


For intLoop = 0 To rs.Fields.Count - 1


strText = strText & rs.fields(intLoop).value & " " & vbCrLf


Next


rs.MoveNext


loop


msgbox strText


end if


set rs = nothing


Main = DTSTaskExecResult_Success


End Function






Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Query output to XML using BCP HELP!! miamikk SQL Language 3 May 15th, 2009 08:22 AM
Output Query to txt file from SQL Query everest SQL Server 2005 4 November 22nd, 2007 01:49 AM
Sql query output to XML or HTML file miamikk SQL Language 4 June 6th, 2007 03:58 AM
Return output variable to VB from SQL stored proc busterbunny BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 1 March 27th, 2006 10:24 PM
Display text data in textarea from SQL query palvin Classic ASP Professional 13 November 30th, 2005 05:52 PM





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