473,799 Members | 3,006 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Search thrue Database

Hey,

I've got the following problem: I'm trying to create a small tool that
must be able to search thrue a database using a search-criteria, that
has to be entered by the user in a TextBox. The results of the search
are displayed in a small datagrid.
My problem is that I've no idea how to create the search functionality
with VB.NET. The datadase used is a smal access database.
Maybe one of you can give me a hint....

Thnx!!

----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 20 '05 #1
3 1178
"Animal" <di**@phantom s-dot-nl.no-spam.invalid> schrieb
I've got the following problem: I'm trying to create a small tool
that must be able to search thrue a database using a search-criteria,
that has to be entered by the user in a TextBox. The results of the
search are displayed in a small datagrid.
My problem is that I've no idea how to create the search
functionality with VB.NET. The datadase used is a smal access
database. Maybe one of you can give me a hint....


Maybe I misunderstood.. .

Use ADO.NET to access the database. Some Keywords:
- System.Data.Ole Db.OleDbConnect ion
- System.Data.Ole Db.OleDbCommand
- System.Data.Ole Db.OleDbDataRea der
- System.Data.Dat aSet

More ADO.NET:
<F1>
VS.NET
.NET Framework
Programming with .NET Framework
-> Accessing Data
VB and VC#
-> Accessing Data
ADO.NET group: microsoft.publi c.dotnet.framew ork.adonet
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
> Armin Zinglerwrote:
"Animal" <di**@phantom s-dot-nl.no-spam.invalid> schrieb
I've got the following problem: I'm trying to create a small tool
that must be able to search thrue a database using a search-criteria, that has to be entered by the user in a TextBox. The results of the
search are displayed in a small datagrid.
My problem is that I've no idea how to create the search
functionality with VB.NET. The datadase used is a smal access
database. Maybe one of you can give me a hint....

Maybe I misunderstood.. .

Use ADO.NET to access the database. Some Keywords:
- System.Data.Ole Db.OleDbConnect ion
- System.Data.Ole Db.OleDbCommand
- System.Data.Ole Db.OleDbDataRea der
- System.Data.Dat aSet

More ADO.NET:
<F1>
VS.NET
.NET Framework
Programming with .NET Framework
-> Accessing Data
VB and VC#
-> Accessing Data
ADO.NET group: microsoft.publi c.dotnet.framew ork.adonet
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html[/quote:eaaae8d79 c]

Armin,

Thnx for the hint!
This is what I tried. The code is based on an example given on the
Microsoft site:
Public Sub ReadMyData(ByVa l myConnString As String)
Dim mySelectQuery As String = "SELECT Doc ID, Subject,
Title, created " & _
"FROM Document WHERE Title LIKE " &
TextBox1.Text
Dim myConnection As New
OleDb.OleDbConn ection(myConnSt ring)
Dim myCommand As New OleDb.OleDbComm and(mySelectQue ry,
myConnection)
myConnection.Op en()
Dim myReader As OleDb.OleDbData Reader =
myCommand.Execu teReader()
Try
While myReader.Read()

Console.WriteLi ne(myReader.Get Int32(0).ToStri ng()
+ ", " _
+ myReader.GetStr ing(1))
End While
Finally
' always call Close when done reading.
myReader.Close( )
' always call Close when done reading.
myConnection.Cl ose()
End Try
End Sub
The sub is called by a click on a button.
As soon as the sub is called I'll get the following error:

"An unhandled exception of typ "System.Data.Ol eDb.OleDbExcept ion"
occured in system.data.dll "

The exception gets raised on the line containing:
[code:1:eaaae8d7 9c]Dim myReader As OleDb.OleDbData Reader =
myCommand.Execu teReader()[/code:1:eaaae8d7 9c]

Does anybody has an idea why this exception is raised??

Thnx!!

----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.co m The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 20 '05 #3
"Animal" <di**@phantom s-dot-nl.no-spam.invalid> schrieb
Public Sub ReadMyData(ByVa l myConnString As String)
Dim mySelectQuery As String = "SELECT Doc ID, Subject,
Title, created " & _
"FROM Document WHERE Title LIKE " &
TextBox1.Text
Dim myConnection As New
OleDb.OleDbConn ection(myConnSt ring)
Dim myCommand As New OleDb.OleDbComm and(mySelectQue ry,
myConnection)
myConnection.Op en()
Dim myReader As OleDb.OleDbData Reader =
myCommand.Execu teReader()
Try
While myReader.Read()

Console.WriteLi ne(myReader.Get Int32(0).ToStri ng()
+ ", " _
+ myReader.GetStr ing(1))
End While
Finally
' always call Close when done reading.
myReader.Close( )
' always call Close when done reading.
myConnection.Cl ose()
End Try
End Sub
The sub is called by a click on a button.
As soon as the sub is called I'll get the following error:

"An unhandled exception of typ "System.Data.Ol eDb.OleDbExcept ion"
occured in system.data.dll "

The exception gets raised on the line containing:
[code:1:eaaae8d7 9c]Dim myReader As OleDb.OleDbData Reader =
myCommand.Execu teReader()[/code:1:eaaae8d7 9c]

Does anybody has an idea why this exception is raised??

You can catch the exception and examine it. Probably there's a syntax error
in the SQL string. Have a look at it.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister. org/news/learn2quote.htm l

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2189
by: WindAndWaves | last post by:
Hi Gurus I am keen to make a search page on a website, but I have absolutely zero experience with PHP. I am going to hire an expert, but I thought that it may pay to try it a bit first myself (I do want to learn how to do it). What I have is a search page (HTML) and an access database. Now, can someone give me some clues or links on where to start. I prefer not to install the whole PHP thing on my own computer, but just to
83
5972
by: D. Dante Lorenso | last post by:
Trying to use the 'search' in the docs section of PostgreSQL.org is extremely SLOW. Considering this is a website for a database and databases are supposed to be good for indexing content, I'd expect a much faster performance. I submitted my search over two minutes ago. I just finished this email to the list. The results have still not come back. I only searched for: SECURITY INVOKER
8
3225
by: Steph | last post by:
Hi. I'm very new to MS Access and have been presented with an Access database of contacts by my employer. I am trying to redesign the main form of the database so that a button entitled 'search' may be clicked on by the user and the user can then search all records by postcode. I want to do this to prevent duplicate data entry.
1
4857
by: jrs_14618 | last post by:
Hello All, This post is essentially a reply a previous post/thread here on this mailing.database.myodbc group titled: MySQL 4.0, FULL-TEXT Indexing and Search Arabic Data, Unicode I was wondering if anybody has experienced the same issues
1
2727
by: Eric | last post by:
Hi: I have two files. I search pattern ":" from emails text file and save email contents into a database. Another search pattern " field is blank. Please try again.", vbExclamation + vbOKOnly Me.txtEmail.SetFocus Exit Sub End If Me.txtStatusBar.Value = "Parsing..." strEmail = Me.txtEmail.Value
5
2695
by: Mark | last post by:
Hi I have an application (in vb.NET 2005) which holds data in SQL Server and some of the SQL records are simply paths to related files. I would like to be able to do a text search on both the SQL data and the contents of any referenced files. The returned list being a listing which includes both records containing the text and files containing the text. Does anyone have a simple example of programatically searching for files
6
4667
by: shantanu | last post by:
Hi All, I have a requirement to develop a search engine based on some search criteria that will search for the string or statement in all the documents uploaded in the website. The search result will be displayed same as the Google Group search, with highlighted texts. I have few questions: 1. What will be the logic to implement? 2. The documents that will be uploaded in the website will be saved in the datbase or not?
1
7554
Merlin1857
by: Merlin1857 | last post by:
How to search multiple fields using ASP A major issue for me when I first started writing in VB Script was constructing the ability to search a table using multiple field input from a form and having the sql statement dynamically built according to the input provided by the user. I have used the method described here hundreds of times it is quick and adaptive. I generally use a frames page for the search, in this way the search is maintained...
5
3706
by: agarwalsrushti | last post by:
hi, This is my the search code i have tried it works well with the fiels stores as string in the database. But i have stored the qualification and specialization as int in database. Each selected value has a unique id. I am not able to search by qualification and specialization fields. If i enter the qualification name in text box then it never displays anything. How can i do it for values stored as int in the table. <html> <head> ...
0
9688
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10490
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10243
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9078
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5590
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4146
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.