473,320 Members | 1,810 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,320 software developers and data experts.

Why am I getting this error in my SQL string?

I get the error that there is "no value given for one or more required parameters" when I attempt to execute this command:

Expand|Select|Wrap|Line Numbers
  1. string commandString = "SELECT moduletitle, unit FROM [EXAMDAT] WHERE moduletitle ='" + modules.SelectedItem.ToString() + "';";
The string looks correct to me, why isn't it working?
Apr 12 '11 #1
4 1141
Stewart Ross
2,545 Expert Mod 2GB
I suspect that the field names you have listed as

[moduletitle, unit]

should be

[moduletitle], [unit]

or more simply

moduletitle, unit

-Stewart
Apr 12 '11 #2
Ah sorry, I changed that. I'm still getting the error though and I'm not sure why.

Here's my full method

Expand|Select|Wrap|Line Numbers
  1. private bool checkSame(string mod, string unit)
  2.         {
  3.             string commandString = "SELECT moduletitle, unit FROM EXAMDAT WHERE moduletitle ='" + modules.SelectedItem.ToString() + "';";
  4.             try
  5.             {
  6.                 OleDbCommand command = new OleDbCommand(commandString, connection);
  7.                 OleDbDataReader reader = command.ExecuteReader();
  8.                 while (reader.Read())
  9.                 {
  10.                     if ((reader["moduletitle"] == modules.SelectedItem.ToString()) && (reader["unit"] == units.SelectedItem.ToString()))
  11.                     {
  12.                         return true;
  13.                     }
  14.                     else
  15.                         return false;
  16.                 }
  17.             }
  18.             catch (Exception e)
  19.             {
  20.                 string exception = "Error in retreiving the data" + e;
  21.                 MessageBox.Show(exception);
  22.                 return false;
  23.             }
  24.  
  25.             return false;
  26.         }
Apr 13 '11 #3
johny10151981
1,059 1GB
print the query,
then copy the query
and then run from your database editing window
which ever software you are using... and see what went wrong

few more things where is your mysql server? if it is in linux server make sure table name you typed it exists. Cause in linux its case sensitive
Apr 13 '11 #4
Plater
7,872 Expert 4TB
Which statement is throwing the error?
What kind of database are you connecting to with the Ole namespace?

It is possible maybe that the [] are being interpreted not as literals but as markers for a parameter and it is complaining that you have not filled in the parameter? [ ] aren't needed around tablenames/columnnames that do not have spaces in them
Apr 13 '11 #5

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

Similar topics

1
by: Elie B. | last post by:
Hi, I'm new to Python. I'm trying to embbed Python in my Windows application having some success with redirecting the stdin/out to my windows application using: In my C++ code I use...
5
by: Yoshitha | last post by:
Hi I am working on a web project. I have a InstallerClass in my project. While making setup ( using web setup template) for this web application, I have added a userinterface with 4...
9
by: Alejandro Forero Cuervo | last post by:
Hello. I'm new to PostgreSQL and I'm using it for some project. I am currently creating an entity engine that provides a web interface, which is oriented towards end users, to...
8
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
4
by: ItsMe | last post by:
Hi Guyz, I'm unable to understand this (AddressOf) error??? In VB6 I have two functions: ---------------------------- Public Function ImageFirstImageCallback(ByVal hWnd As Integer, ByVal...
5
by: Archana | last post by:
Hi all, I am having application where i am downloading xml content using webrequest. my code is as below HttpWebRequest lWebRequest = (HttpWebRequest) WebRequest.Create(URL); HttpWebResponse...
7
vikas251074
by: vikas251074 | last post by:
I am getting error above in following code since few days giving tension day and night. How can I solve this? I am facing since Oct.25. in line no. 362 After doing a lot of homework, I am...
1
by: NareshN | last post by:
Hi, I am getting error because of this line in stored procedure.How to enclose string value. Count(Case When Totalhours<='25:0' Then EmpNo end) as Less. 25:0 is varchar datatype so i am...
0
by: Chocolade | last post by:
If im using this code just on a text file i created that containing one long string like "dann123ylip123sharon123daniel" so its working im ggeting first time result : "dann" then "dannylip" then...
1
by: Omendra | last post by:
Hi, I am using SQL Server 2005 and i am using Stored Procedure something like :- I am getting error:- Msg 170, Level 15, State 1, Line 18: Incorrect syntax near 'MAX'. DECLARE @jid AS...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.