Click here to Skip to main content
12,239,805 members (52,177 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB VB.NET
HI. I am working with MS Access and vb.net . but i am finding it difficult to create a search textbox which will allow me to retrieve a specific record from Ms access database by inputting a value into a search box and the search results displayed into text boxes on the visual basic form. Meanwhile i have already attached my Ms Access database to my vb project Please help... thanks.
Posted 6-Dec-12 5:46am
TugBest604
Comments
ryanb31 6-Dec-12 12:23pm
   
We need more info. Where are you stuck?
Samuel S. A Avortri 15-Dec-12 7:47am
   
i Code this code and it is working perfecting for my results displaying in the text boxes. but my results must come with a picture in a picturebox on the form. I don't how i can get my picture to display in the picture box with the other search results in the textboxes.
i have erors like:- ("Unable to cast object of type 'System.Byte[]' to type 'System.Drawing.Image'")
THIS IS THE CODE BELOW.
NB: the commented code is where am facing problem.

Dim strsql As String = "select FullName,DateofBirth,Emailaddress,Pictures from EntDb where FullName like('" + TextBox11.Text + "%')"
Dim strcon As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Avo\Documents\chk.accdb"
Dim odapre As New OleDb.OleDbDataAdapter(strsql, strcon)
Dim datTable As New DataTable
Dim incount As Integer
odapre.Fill(datTable)
For incount = 0 To datTable.Rows.Count - 1
FullNameTextBox1.Text = datTable.Rows(incount)("Fullname").ToString
DateofBirthDateTimePicker.Text = datTable.Rows(incount)("DateofBirth").ToString
EmailaddressTextBox.Text = datTable.Rows(incount)("Emailaddress").ToString
' PicturesPictureBox1. = datTable.Rows(incount)("Pictures")
next
end sub
ridoy 6-Dec-12 13:37pm
   
need some clear info here..do you want autocompleteness for you textbox(as like google search textbox) where the matching values with input would be shown form your database?
Samuel S. A Avortri 15-Dec-12 10:12am
   
i want matching values with input to be shown from my database with the matching picture in a picturebox. Everything works when i comment out the picture code.
so i need a little help for the picture to display in a picturebox.

i have erors like:- ("Unable to cast object of type 'System.Byte[]' to type 'System.Drawing.Image'")
THIS IS MA CODE:
Dim strsql As String = "select FullName,DateofBirth,Emailaddress,Pictures from EntDb where FullName like('" + TextBox11.Text + "%')" Dim strcon As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Avo\Documents\chk.accdb" Dim odapre As New OleDb.OleDbDataAdapter(strsql, strcon) Dim datTable As New DataTable Dim incount As Integer odapre.Fill(datTable)

For incount = 0 To datTable.Rows.Count - 1

FullNameTextBox1.Text = datTable.Rows(incount)("Fullname").ToString

DateofBirthDateTimePicker.Text = datTable.Rows(incount("DateofBirth").ToString
EmailaddressTextBox.Text = datTable.Rows(incount)("Emailaddress").ToString
' PicturesPictureBox1.image = datTable.Rows(incount)("Pictures")
next
end sub

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Don *NOT* use a text box to display your results.

Here is some reading for you, after which you should be able to bang this out in minutes.

Parameterized Queries[^] - Great Post

Use that to get a data table and read this
DataGridView[^]

Then look at this to run your queries in the background to not stop your thread
BackgroundWorker[^]

Then tie into your textbox OnChange (or KeyUp depending on your requirements) to run the query in the background and populate the DataGridView.
  Permalink  
Comments
Samuel S. A Avortri 15-Dec-12 7:54am
   
thanks very much

i Code this code and it is working perfecting for my results displaying in the text boxes. but my results must come with a picture in a picturebox on the form. I don't how i can get my picture to display in the picture box with the other search results in the textboxes.

THIS IS THE CODE BELOW.
NB: the commented code is where am facing problem.

Dim strsql As String = "select FullName,DateofBirth,Emailaddressfrom Entdb where FullName like('" + TextBox11.Text + "%')"
Dim strcon As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Avo\Documents\chk.accdb"
Dim odapre As New OleDb.OleDbDataAdapter(strsql, strcon)
Dim datTable As New DataTable
Dim incount As Integer
odapre.Fill(datTable)
For incount = 0 To datTable.Rows.Count - 1
FullNameTextBox1.Text = datTable.Rows(incount)("Fullname").ToString
DateofBirthDateTimePicker.Text = datTable.Rows(incount)("DateofBirth").ToString
EmailaddressTextBox.Text = datTable.Rows(incount)("Emailaddress").ToString
' PicturesPictureBox1. = datTable.Rows(incount)("Pictures")
next
end sub

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 6 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100