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 1687
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: 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...
|
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: 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: 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...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
| |