473,387 Members | 3,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to work on SQL Subqueries with OleDbDataReader?

1
Whenever I run the code, I get an exception "No value given for one or more required parameters". I don't find anything wrong with the SQL statement (or are there any?). Basically I'm trying to get the user input and look for the corresponding CourseNumber then match the CourseNumber and TopicNumber. Then I will look up for the TopicName using TopicNumber.

Expand|Select|Wrap|Line Numbers
  1.    protected void AddAssignment()
  2.         {
  3.             OleDbConnection conn = null;
  4.             OleDbDataReader reader;
  5.             try
  6.             {
  7.                 conn = new OleDbConnection("Provider=Microsoft.Jet.OleDB.4.0;" + "Data Source=" + Server.MapPath("~/Data/RPMH.mdb"));
  8.  
  9.                 conn.Open();
  10.  
  11.                 OleDbCommand cmd = new OleDbCommand("SELECT TopicName FROM Topic WHERE TopicNumber IN (SELECT TopicNumber FROM CourseTopic WHERE CourseNumber = (SELECT CourseNumber FROM Course WHERE CourseName ='"+AddClass.courseselect+"'))", conn);
  12.  
  13.                 TopicList.DataValueField = "Topic";
  14.                 TopicList.DataTextField = "Topic";
  15.  
  16.                while (reader.Read())
  17.                 {
  18.                     ListItem newItem = new ListItem();
  19.                     newItem.Value = (string)reader["TopicName"];
  20.                     newItem.Text = (string)reader["TopicName"];
  21.                     TopicList.Items.Add(newItem);
  22.                 }
  23.                 reader.Close();
  24.             }
  25.             finally
  26.             {
  27.                 if (conn != null)
  28.                     conn.Close();
  29.             }
  30.         }
  31.  
May 11 '11 #1
0 1152

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Daniel Elliott | last post by:
Hello, I was wondering if anyone would be able to help me with a problem I'm having. I'm trying to use the following query: SELECT Distinct c.site_id FROM campsite c WHERE c.site_id NOT IN...
5
by: Nick | last post by:
Im moving a development app (MySQL 5.0) to a different server which runs MySQL 4.0.20-standard. I am getting errors on queries that have subqueries such as... SELECT id FROM table1 WHERE id IN...
10
by: Dion Heskett | last post by:
I wish to supply the formating as a parameter, I have tried OleDbDataReader but get a null ref. just can't seem to get this to work. I think this has something to do with ExecuteReader. also...
0
by: Steve1 via DotNetMonster.com | last post by:
Hi all, I''ve created an OleDbDataReader that will contain the number of records that the used SQL query will return. I'm then using a while loop to loop while the OleDBDataReader object has...
1
by: Rob Richardson | last post by:
Greetings! I have a database created in MS Access that has some fields containing Currency data. Every time I try to use one of the OleDbDataReader's GetXXX() methods to read it, I get an...
0
by: Bob | last post by:
Hi, I have a very odd postgresql problem. I have some subqueries contained within a function which are looking for unrefernced data and then delete any rows that are found: CREATE OR...
1
by: RoseM | last post by:
Hi again, I could use some help and have not been able to come to grips with what I need to do to make this work. I have a table of theories and votes and I want to return the percent to total...
4
by: muzu1232004 | last post by:
Can anyone explain me when we use correlated subqueries rather than nested subqueries. Do all the correlated subqueries can be written in nested subqueries form as well ? What are the major...
0
debasisdas
by: debasisdas | last post by:
Using Subqueries ================== The sub query is often referred to as a nested SELECT, Sub - SELECT, or inner SELECT statement. The sub query executes once before the main query. The...
1
by: lizandra | last post by:
Greetings, I am a newbie, I have been working to extract data from a basic sales db and trying to decide when I should use joins and when I should use subqueries. Much of what I read online says...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.