Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / January 2006

Tip: Looking for answers? Try searching our database.

Viewing ExecuteQuery String

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jim_adams@hotmail.com - 13 Jan 2006 15:37 GMT
Given a technique similar to the following, instead of actually
executing the Stored Procedure, I need the resulting SQL command string
written to a file and then manually executed in Query Analyzer.

Dim objSqlConn As New SqlClient.SqlConnection
Dim objSqlDA As New SqlClient.SqlDataAdapter
Dim objSqlCmd As New SqlClient.SqlCommand
objSqlConn = New SqlConnection(strSqlConn)
With objSqlCmd
    objSqlConn.Open()
    .CommandTimeout = CommandTimeout
    .CommandType = CommandType.StoredProcedure
    'Add some SPROC parameters
    .Parameters.Add(DbParameter)
    .CommandText = Command
    .Connection = objSqlConn
End With
objSqlDA.SelectCommand = objSqlCmd
if blnWriteToScriptFile then
    'How to do this????????
else
    objSqlDA.Fill(objDS)
end if

Any ideas are greatly appreciated?

Thanks,

Jim
William (Bill) Vaughn - 13 Jan 2006 18:51 GMT
The final product generated by ADO.NET is not exposed as a public property
unless you enable Trace. What you can do is use the Profiler to see what's
generated and sent to the server.

Signature

____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

> Given a technique similar to the following, instead of actually
> executing the Stored Procedure, I need the resulting SQL command string
[quoted text clipped - 25 lines]
>
> Jim
jim_adams@hotmail.com - 13 Jan 2006 19:40 GMT
Hi Bill,

Thanks for the suggestion.

The problem is that to generate the Trace, the SQL statements have to
be run.  Certain times, especially when dealing with shared SQL
clusters, a DBA needs to manually review and run scripts via Query
Analyzer.  Having a binary app do this without DBA review is against
policy.  So in this case, instead of running the SPROCS, my app needs
to produce a work file.

Thanks again for your help.

Jim

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.