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

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 1158
"Animal" <di**@phantoms-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.OleDb.OleDbConnection
- System.Data.OleDb.OleDbCommand
- System.Data.OleDb.OleDbDataReader
- System.Data.DataSet

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

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

Nov 20 '05 #2
> Armin Zinglerwrote:
"Animal" <di**@phantoms-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.OleDb.OleDbConnection
- System.Data.OleDb.OleDbCommand
- System.Data.OleDb.OleDbDataReader
- System.Data.DataSet

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

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

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(ByVal 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.OleDbConnection(myConnString)
Dim myCommand As New OleDb.OleDbCommand(mySelectQuery,
myConnection)
myConnection.Open()
Dim myReader As OleDb.OleDbDataReader =
myCommand.ExecuteReader()
Try
While myReader.Read()

Console.WriteLine(myReader.GetInt32(0).ToString()
+ ", " _
+ myReader.GetString(1))
End While
Finally
' always call Close when done reading.
myReader.Close()
' always call Close when done reading.
myConnection.Close()
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.OleDb.OleDbException"
occured in system.data.dll"

The exception gets raised on the line containing:
[code:1:eaaae8d79c]Dim myReader As OleDb.OleDbDataReader =
myCommand.ExecuteReader()[/code:1:eaaae8d79c]

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

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 #3
"Animal" <di**@phantoms-dot-nl.no-spam.invalid> schrieb
Public Sub ReadMyData(ByVal 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.OleDbConnection(myConnString)
Dim myCommand As New OleDb.OleDbCommand(mySelectQuery,
myConnection)
myConnection.Open()
Dim myReader As OleDb.OleDbDataReader =
myCommand.ExecuteReader()
Try
While myReader.Read()

Console.WriteLine(myReader.GetInt32(0).ToString()
+ ", " _
+ myReader.GetString(1))
End While
Finally
' always call Close when done reading.
myReader.Close()
' always call Close when done reading.
myConnection.Close()
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.OleDb.OleDbException"
occured in system.data.dll"

The exception gets raised on the line containing:
[code:1:eaaae8d79c]Dim myReader As OleDb.OleDbDataReader =
myCommand.ExecuteReader()[/code:1:eaaae8d79c]

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.html

Nov 20 '05 #4

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

Similar topics

7
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...
83
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...
8
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...
1
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...
1
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...
5
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...
6
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...
1
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...
5
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...
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
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.