PC Review


Reply
Thread Tools Rate Thread

Search Box Bizarre Behaviour

 
 
Aziz
Guest
Posts: n/a
 
      24th Apr 2006
I have created a search box that will compare the entered text with a
list of database entries and return the matches to a DataTable and
DataGrid

Private Sub txtProductCode_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles txtProductCode.TextChanged

Dim dtProductSearch As DataTable = New
DataTable("ProductSearch")
Dim dcProductSearch As DataColumn

dcProductSearch = New DataColumn
dcProductSearch.ColumnName = "ProductCode"
dtProductSearch.Columns.Add(dcProductSearch)
dcProductSearch.DataType = System.Type.GetType("System.String")
dcProductSearch = New DataColumn
dcProductSearch.ColumnName = "ProductDescription"
dcProductSearch.DataType = System.Type.GetType("System.String")
dtProductSearch.Columns.Add(dcProductSearch)
dcProductSearch = New DataColumn
dcProductSearch.ColumnName = "ProductAlloyCode"
dcProductSearch.DataType = System.Type.GetType("System.String")
dtProductSearch.Columns.Add(dcProductSearch)


Dim strSearched As String
strProductCode = txtProductCode.Text.ToUpper

Dim i As Integer
For i = 0 To dsTurbobraze.Product.Rows.Count - 1
strSearched =
dsTurbobraze.Product.Rows(i).Item("ProductCode").ToString

If InStr(strSearched, txtProductCode1.Text) > 0 Then
drProductSearch = dtProductSearch.NewRow()
drProductSearch("ProductCode") =
dsTurbobraze.Product.Rows(i).Item("ProductCode").ToString
drProductSearch("ProductDescription") =
dsTurbobraze.Product.Rows(i).Item("ProductDescription").ToString
drProductSearch("ProductAlloyCode") =
dsTurbobraze.Product.Rows(i).Item("AlloyCode").ToString
dtProductSearch.Rows.Add(drProductSearch)
dgrProductSearch.DataSource = dtProductSearch
End If
Next i
End Sub

I have 4 entries in the DataBase:
CHIAF-50-5-K2
CHIAF-50-5-K3
CHIAF-50-5-I4
CHIAF-50-5-M2

If I enter upto "CHIAF-50-5-" in the search box all results show up but
if I add a "K" nothing shows, if I add an "I" nothing shows, but if I
add an "M" it DOES show, and continues to show if I add a "2" to the
"M".

If I enter "K" on it's own, nothing shows, same with "I", but if I
enter "M" the correct product shows.

It seems to be a problem to do with the fact that either VB can't read
the last two letters of the ProductCode for all roducts except the last
one, or it can read it but can't process it for some reason.

 
Reply With Quote
 
 
 
 
Aziz
Guest
Posts: n/a
 
      24th Apr 2006
If I output the contents of the DataSet the DataGrid is based on it
shows that when I type "K" the first two entries DO get added, they
just don't display in the DataGrid.

Debug.WriteLine(dtProductSearch.Rows.Count)
Dim i As Integer
For i = 0 To dtProductSearch.Rows.Count - 1
Debug.WriteLine(dtProductSearch.Rows(i).Item(0).ToString)
Next

When strSearched (string to look for) is "K" it gives:
2
CHIAF-50-5-K2
CHIAF-50-5-K3

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bizarre Title & Text-Box Behaviour Sean Microsoft Excel Charting 0 30th Jan 2008 05:00 PM
Bizarre laptop behaviour on system start =?Utf-8?B?Y2hyb21pYW4=?= Microsoft Windows 2000 1 2nd Jun 2005 08:26 PM
Help Pls: Bizarre TrackBar Behaviour With Large Values Pls Help Microsoft Dot NET 1 25th May 2004 11:27 AM
Help Pls: Bizarre TrackBar Behaviour With Large Values Pls Help Microsoft Dot NET Framework Forms 1 25th May 2004 11:27 AM
Bizarre Network Behaviour Grand Nasal Microsoft Windows 2000 Networking 0 4th Dec 2003 02:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:04 PM.