Printing out sql query on screen

I would like to be able to see my sql querys on screen (or in any other way) when debugging.

In classing asp I could just print out the query with it's values like

sql = "Select * from table where id = " & request("id")
set rs = conn.execute(sql)
response.write(sql)

then I could see what values where in the query.

How can I get a similar result in asp.net?
Peter NordbergIT ManagerAsked:
Who is Participating?
 
Bob LearnedConnect With a Mentor Commented:
Dim commandText As String = "Select * From Users Where Name = 'Bob' "
System.Diagnostics.Debug.WriteLine(commandText)

Bob
0
 
RamuncikasCommented:
   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim sql As String
        Sql = "Select * from table where id = " & Request("id")
        Response.Write(Sql)
    End Sub
0
 
Bob LearnedCommented:
You can also use System.Diagnostics.Debug.WriteLine to set it in the Output window.

Bob
0
 
Peter NordbergIT ManagerAuthor Commented:
How do I do that?
0
 
Peter NordbergIT ManagerAuthor Commented:
ok, I'll try
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.