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

ASP.NET problem

alright, first of all i love thise site, helped me out alot alreaddy, but now i have a problem witch i cant find a answer to after a LONG time of searching.

I am trying to make a small search, witch will search true my database table called "serials" in the colum "SoftwareName" for a match. but im having the biggest trouble in making it work. this is my code atm:

Expand|Select|Wrap|Line Numbers
  1.     protected void btn_search_Click(object sender, EventArgs e)
  2.     {
  3.  
  4.         string search = box_searchfor.Text;
  5.  
  6.         string constring = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath("database.mdb");
  7.         string SQLvraag = "SELECT * FROM serials WHERE SoftwareName= " + "box_searchfor.Text";
  8.         OleDbConnection dbconnectie = new OleDbConnection(constring);
  9.  
  10.  
  11.         // show the search results
  12.         try
  13.         {
  14.             dbconnectie.Open();
  15.             OleDbCommand cmd = new OleDbCommand(SQLvraag, dbconnectie);
  16.             OleDbDataReader dr = cmd.ExecuteReader();
  17.  
  18.             lbl_result.Text = "";
  19.  
  20.             if (dr.HasRows)
  21.             {
  22.                 while (dr.Read())
  23.                 {
  24.                     lbl_result.Text += dr["SoftwareName"].ToString() + "<br /> ";
  25.                 }
  26.             }
  27.             else
  28.             {
  29.                 lbl_result.Text = "Geen serial's gevonden.";
  30.             }
  31.  
  32.         }
  33.  
  34.         catch (Exception ex)
  35.         {
  36.             lbl_result.Text = "Probleem met database" + "<br /><br />" + ex.ToString();
  37.         }
  38.  
  39.         finally
  40.         {
  41.             dbconnectie.Close();
  42.         }
  43.     }
  44.  
and i am getting this error:

Expand|Select|Wrap|Line Numbers
  1. System.Data.OleDb.OleDbException: Waarden voor een of meer vereiste parameters ontbreken. at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.OleDb.OleDbCommand.ExecuteReader() at _Default.btn_search_Click(Object sender, EventArgs e) in d:\Mijn Documenten\Visual Studio 2005\WebSites\Richards project\Seriallist.aspx.cs:line 80
this is line 80:
Expand|Select|Wrap|Line Numbers
  1. OleDbDataReader dr = cmd.ExecuteReader();
im desperate, that has nothing to do with my query! :S please help me out

Richard S
Apr 10 '07 #1
7 1687
prabunewindia
199 100+
hi friend,
i think the problem with ur query.
SELECT * FROM serials WHERE SoftwareName= " + "box_searchfor.Text";

try it

SELECT * FROM serials WHERE SoftwareName= '" + box_searchfor.Text+"'";
just copy this and replace the old one and try


alright, first of all i love thise site, helped me out alot alreaddy, but now i have a problem witch i cant find a answer to after a LONG time of searching.

I am trying to make a small search, witch will search true my database table called "serials" in the colum "SoftwareName" for a match. but im having the biggest trouble in making it work. this is my code atm:

Expand|Select|Wrap|Line Numbers
  1.     protected void btn_search_Click(object sender, EventArgs e)
  2.     {
  3.  
  4.         string search = box_searchfor.Text;
  5.  
  6.         string constring = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath("database.mdb");
  7.         string SQLvraag = "SELECT * FROM serials WHERE SoftwareName= " + "box_searchfor.Text";
  8.         OleDbConnection dbconnectie = new OleDbConnection(constring);
  9.  
  10.  
  11.         // show the search results
  12.         try
  13.         {
  14.             dbconnectie.Open();
  15.             OleDbCommand cmd = new OleDbCommand(SQLvraag, dbconnectie);
  16.             OleDbDataReader dr = cmd.ExecuteReader();
  17.  
  18.             lbl_result.Text = "";
  19.  
  20.             if (dr.HasRows)
  21.             {
  22.                 while (dr.Read())
  23.                 {
  24.                     lbl_result.Text += dr["SoftwareName"].ToString() + "<br /> ";
  25.                 }
  26.             }
  27.             else
  28.             {
  29.                 lbl_result.Text = "Geen serial's gevonden.";
  30.             }
  31.  
  32.         }
  33.  
  34.         catch (Exception ex)
  35.         {
  36.             lbl_result.Text = "Probleem met database" + "<br /><br />" + ex.ToString();
  37.         }
  38.  
  39.         finally
  40.         {
  41.             dbconnectie.Close();
  42.         }
  43.     }
  44.  
and i am getting this error:

Expand|Select|Wrap|Line Numbers
  1. System.Data.OleDb.OleDbException: Waarden voor een of meer vereiste parameters ontbreken. at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.OleDb.OleDbCommand.ExecuteReader() at _Default.btn_search_Click(Object sender, EventArgs e) in d:\Mijn Documenten\Visual Studio 2005\WebSites\Richards project\Seriallist.aspx.cs:line 80
this is line 80:
Expand|Select|Wrap|Line Numbers
  1. OleDbDataReader dr = cmd.ExecuteReader();
im desperate, that has nothing to do with my query! :S please help me out

Richard S
Apr 11 '07 #2
AWESOME! thanks man :D really helped (and it worked :P)

but now i have the following thing, in my table i have a row with SoftwareName: Richard

now if i search for R, it finds nothing, and if i search for Richard, it does. how do i fix this?

i tried using this query:

"SELECT * FROM serials WHERE SoftwareName= '" + "*" + box_searchfor.Text + "*" + "'"

but if i use that, it finds nothing, even when i search for Richard, wich is found with
"SELECT * FROM serials WHERE SoftwareName= '" + box_searchfor.Text + "'"
Apr 11 '07 #3
gomzi
304 100+
AWESOME! thanks man :D really helped (and it worked :P)

but now i have the following thing, in my table i have a row with SoftwareName: Richard

now if i search for R, it finds nothing, and if i search for Richard, it does. how do i fix this?

i tried using this query:

"SELECT * FROM serials WHERE SoftwareName= '" + "*" + box_searchfor.Text + "*" + "'"

but if i use that, it finds nothing, even when i search for Richard, wich is found with
"SELECT * FROM serials WHERE SoftwareName= '" + box_searchfor.Text + "'"
Try this,
select * from serials where SoftwareName = "%" + '" + box_searchfor.Text + "' + "%"
Apr 11 '07 #4
Try this,
select * from serials where SoftwareName = "%" + '" + box_searchfor.Text + "' + "%"

"select * from serials where SoftwareName = " % " + '" + box_searchfor.Text + "' + " % "";

that gives me the following error:
Operator '%' cannot be applied to operands of type 'string' and 'string'

on 2 locations:

"select * from serials where SoftwareName = "

and on:

"' + "

:(
Apr 11 '07 #5
ups, sorry i did something wrong!

i use this query now:
"select * from serials where SoftwareName = "%" + '" + box_searchfor.Text + "' + "%";

witch gives me this error:
Newline in constant (this is selected when i double click the error: ";)
Apr 11 '07 #6
alright, srry for tripple post guys, but i figured it out, and i thought id let you guys know how...

Try this,
select * from serials where SoftwareName = "%" + '" + box_searchfor.Text + "' + "%"
this is the query i came up with:

Expand|Select|Wrap|Line Numbers
  1. "select * from serials where SoftwareName LIKE '%" + search + "%'"
the problem was that "SoftwareName =" should be "SoftwareName LIKE", LIKE helps you search for patterns :) so this fixed it!

thanks for helping guys!
Apr 11 '07 #7
gomzi
304 100+
alright, srry for tripple post guys, but i figured it out, and i thought id let you guys know how...



this is the query i came up with:

Expand|Select|Wrap|Line Numbers
  1. "select * from serials where SoftwareName LIKE '%" + search + "%'"
the problem was that "SoftwareName =" should be "SoftwareName LIKE", LIKE helps you search for patterns :) so this fixed it!

thanks for helping guys!
great!! sorry that i said = instead of like.
Apr 11 '07 #8

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

Similar topics

11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
117
by: Peter Olcott | last post by:
www.halting-problem.com
18
by: Ian Stanley | last post by:
Hi, Continuing my strcat segmentation fault posting- I have a problem which occurs when appending two sting literals using strcat. I have tried to fix it by writing my own function that does the...
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
0
by: =?Utf-8?B?am8uZWw=?= | last post by:
Hello All, I am developing an Input Methop (IM) for PocketPC / Windows Mobile (PPC/WM). On some devices the IM will not start. The IM appears in the IM-List but when it is selected from the...
1
by: sherifbk | last post by:
Problem description ============== - I have 4 clients and 1 server (SQL server) - 3 clients are Monitoring console 1 client is operation console - Monitoring console collects some data from...
9
by: AceKnocks | last post by:
I am working on a framework design problem in which I have to design a C++ based framework capable of solving three puzzles for now but actually it should work with a general puzzle of any kind and I...
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...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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...
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...

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.