Solved

output my sql query to the web page for debug / testing

Posted on 2008-10-31
3
209 Views
Last Modified: 2012-05-05
hello,

i have a sql query that takes i want to pass values from form field inputs (Session, MachineName, JobType). If i hard code the values in the query it works fine, its just not displaying anything when i try ti read in from the form fields.

in php ive been able to print the sql query with all the variables, etc. to the screen to verify im getting the correct data. how would i go about doing this in asp.net?

Thanks


example query below


select * from TableName
 
WHERE     
(dbo.tbl_Datasheets_Machines_DataSet.Site LIKE '%' + ? + '%') 
AND (dbo.tbl_Datasheet_Users_DataSet.Session = ?) 
AND (dbo.tbl_Datasheet_Positions_DataSet.Position LIKE '%' + ? + '%') 
AND (dbo.tbl_Datasheets_Customer_DataSet.User_Type = 'Advanced')
 
ORDER BY dbo.tbl_Datasheets_Machines_DataSet.Machine_Name ASC">
 
 
        
        </script>
    
        <SelectParameters>
        <asp:ControlParameter ControlID="MachineName" Name="Machine_Name" 
            PropertyName="Text" Type="String" />
        <asp:ControlParameter ControlID="Position" Name="Position" PropertyName="Text" 
            Type="String" />
        <asp:ControlParameter ControlID="SessionTime" Name="Session" 
            PropertyName="Text" Type="String" />
    </SelectParameters>

Open in new window

0
Comment
Question by:nriddock
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 3

Expert Comment

by:ahll
ID: 22853751
Hi...I'm a little confused. Your code is not complete.

Anyway..if thats is the exacu query you are using, you have to especify the paramneters in there. it should look like this:

select * from TableName
 
WHERE     
(dbo.tbl_Datasheets_Machines_DataSet.Site LIKE '%' + @MachineName+ '%') 
AND (dbo.tbl_Datasheet_Users_DataSet.Session = @Session) 
AND (dbo.tbl_Datasheet_Positions_DataSet.Position LIKE '%' + @Position + '%') 
AND (dbo.tbl_Datasheets_Customer_DataSet.User_Type = 'Advanced')
 
ORDER BY dbo.tbl_Datasheets_Machines_DataSet.Machine_Name ASC

Open in new window

0
 

Author Comment

by:nriddock
ID: 22853829
i appreciate the updated code...do you know of a way to output the sql query as its executed so i can debug/test.

ie:

<pseduocode>

echo "$sqlQuery;"
</pseudocode>

Would output on the screen

select * from TableName WHERE    
(dbo.tbl_Datasheets_Machines_DataSet.Site LIKE NY107A100)
AND (dbo.tbl_Datasheet_Users_DataSet.Session = AM)
AND (dbo.tbl_Datasheet_Positions_DataSet.Position LIKE Manager)
AND (dbo.tbl_Datasheets_Customer_DataSet.User_Type = Advanced)
 
ORDER BY dbo.tbl_Datasheets_Machines_DataSet.Machine_Name ASC
0
 
LVL 3

Accepted Solution

by:
ahll earned 500 total points
ID: 22853942
What happened with that code?...Did it work? You might to play with the quotes too.
Could you paste the whole DataSourde code?...It would help a lot.

If you are using a SQLDataSource I dont know how to see the whole query with the parameters already included.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question