473,326 Members | 2,805 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,326 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 1682
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...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.