Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET 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 December 22nd, 2003, 06:41 PM
Authorized User
 
Join Date: Aug 2003
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default Nested Query Trouble

Hi, guys. I'm having a slight problem trying to do a nested query in visual basic .net. I'm currently using an SQLDataReader to retrieve the data that the query should be returning. It seems, however, that the query itself is not returning anything because the DataReader gives me an error. Anyway, here is my current query:

 sqlGetScheduledEmp =
"SELECT FirstName, LastName
FROM Personnel
WHERE (SNo =
(SELECT SNo FROM PostAssignments WHERE (shiftID = '" & cboShift.Text & "' AND (postID =
(SELECT postID FROM Posts WHERE Unit = '" & txtUnit.Text & "' AND Post='" & cboAssignments.Text & "'))))"

I know the nested query itself works in SQL Server when I hard code the values. I have tried hard coding the values in .net, but I still get an error. Any suggestions would be VERY helpful, as I'm about to pull my hair out! ;)

 
Old December 23rd, 2003, 05:05 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Hope you're not bald by now ;)

Anyway, count your parentheses. The SQL statement uses 5 opening ( characters, and only four to close them again.

The easiest thing to test these kind of things is to put the entire SQL statement on a label on the page, right before you send the data to the database. Then paste the statement in the Query Analyzer and see if it works.....

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old December 23rd, 2003, 01:32 PM
Authorized User
 
Join Date: Aug 2003
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, I finally figured it out last night. I had too many parentheses in there period! ;)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Nested query deb1980 ASP.NET 2.0 Basics 2 April 10th, 2007 04:38 AM
Nested Query teclo MySQL 1 March 22nd, 2005 07:20 AM
Nested Query BrianWren Oracle 5 February 1st, 2005 01:45 PM
nested insert query/...how? mch SQL Server 2000 2 April 28th, 2004 08:46 AM
Nested Query Trouble ashley_y VB How-To 1 December 23rd, 2003 05:10 AM





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