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: -
protected void btn_search_Click(object sender, EventArgs e)
-
{
-
-
string search = box_searchfor.Text;
-
-
string constring = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath("database.mdb");
-
string SQLvraag = "SELECT * FROM serials WHERE SoftwareName= " + "box_searchfor.Text";
-
OleDbConnection dbconnectie = new OleDbConnection(constring);
-
-
-
// show the search results
-
try
-
{
-
dbconnectie.Open();
-
OleDbCommand cmd = new OleDbCommand(SQLvraag, dbconnectie);
-
OleDbDataReader dr = cmd.ExecuteReader();
-
-
lbl_result.Text = "";
-
-
if (dr.HasRows)
-
{
-
while (dr.Read())
-
{
-
lbl_result.Text += dr["SoftwareName"].ToString() + "<br /> ";
-
}
-
}
-
else
-
{
-
lbl_result.Text = "Geen serial's gevonden.";
-
}
-
-
}
-
-
catch (Exception ex)
-
{
-
lbl_result.Text = "Probleem met database" + "<br /><br />" + ex.ToString();
-
}
-
-
finally
-
{
-
dbconnectie.Close();
-
}
-
}
-
and i am getting this error: - 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: - OleDbDataReader dr = cmd.ExecuteReader();
im desperate, that has nothing to do with my query! :S please help me out
Richard S
7 1682
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: -
protected void btn_search_Click(object sender, EventArgs e)
-
{
-
-
string search = box_searchfor.Text;
-
-
string constring = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath("database.mdb");
-
string SQLvraag = "SELECT * FROM serials WHERE SoftwareName= " + "box_searchfor.Text";
-
OleDbConnection dbconnectie = new OleDbConnection(constring);
-
-
-
// show the search results
-
try
-
{
-
dbconnectie.Open();
-
OleDbCommand cmd = new OleDbCommand(SQLvraag, dbconnectie);
-
OleDbDataReader dr = cmd.ExecuteReader();
-
-
lbl_result.Text = "";
-
-
if (dr.HasRows)
-
{
-
while (dr.Read())
-
{
-
lbl_result.Text += dr["SoftwareName"].ToString() + "<br /> ";
-
}
-
}
-
else
-
{
-
lbl_result.Text = "Geen serial's gevonden.";
-
}
-
-
}
-
-
catch (Exception ex)
-
{
-
lbl_result.Text = "Probleem met database" + "<br /><br />" + ex.ToString();
-
}
-
-
finally
-
{
-
dbconnectie.Close();
-
}
-
}
-
and i am getting this error: - 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: - OleDbDataReader dr = cmd.ExecuteReader();
im desperate, that has nothing to do with my query! :S please help me out
Richard S
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 + "'"
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 + "' + "%"
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:
"' + "
:(
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: ";)
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: - "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!
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: - "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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
by: Peter Olcott |
last post by:
www.halting-problem.com
|
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...
|
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();...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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
|
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...
| |