473,326 Members | 2,127 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,326 software developers and data experts.

Search Box Bizarre Behaviour

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").T oString

If InStr(strSearched, txtProductCode1.Text) > 0 Then
drProductSearch = dtProductSearch.NewRow()
drProductSearch("ProductCode") =
dsTurbobraze.Product.Rows(i).Item("ProductCode").T oString
drProductSearch("ProductDescription") =
dsTurbobraze.Product.Rows(i).Item("ProductDescript ion").ToString
drProductSearch("ProductAlloyCode") =
dsTurbobraze.Product.Rows(i).Item("AlloyCode").ToS tring
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.

Apr 24 '06 #1
1 976
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).To String)
Next

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

Apr 24 '06 #2

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

Similar topics

4
by: The Plankmeister | last post by:
This really is very strange... Have a look at this: http://www.plankmeister.org.uk/new/index.html in IE6. When it loads, the top section is blank. If you mouseover anything in the menu half of...
4
by: Wayne Aprato | last post by:
I have a simple database which was originally written in Access 97. When converted to Access 2000 file format it ran flawlessly in Access 2002. I've just tried to run it in Access 2003 and I am...
14
by: Nick Maclaren | last post by:
x = (1.234567890125, 1.2345678901255) print x print x, x Is there a rational reason, or is that simply an artifact of the way that the code has evolved? It is clearly not a bug :-) ...
4
by: Sean Inglis | last post by:
Well bizarre to me, anyway. I've distilled it down to two small files: testtop.htm =============================== <html> <head> <script language="Javascript">
4
by: Neo Geshel | last post by:
Just moved to C# from VB.NET, frustrated to hell and back by inability to get much-copied (from about 20+ different resources) literal example to work. Master Page content: <meta...
9
by: ckfan.painter | last post by:
I've run into a seemingly bizarre problem with insert() for std::vector. (This was done on Microsoft Visual C++ 2005 express version 8...maybe it is a compiler specific bug?) Here's the code: ...
35
by: bukzor | last post by:
I've found some bizzare behavior when using mutable values (lists, dicts, etc) as the default argument of a function. I want to get the community's feedback on this. It's easiest to explain with...
0
by: =?Utf-8?B?bXVzb3NkZXY=?= | last post by:
Hi guys I'm using a URLRewrite module to redirect certain URLs in my .net 2.0 website. However I am getting som really bizarre behaviour public void UrlRewriter_BeginRequest(object sender,...
20
by: Jasper | last post by:
I'm stumped. I'm calling a method that has keyword args, but not setting them, and yet one of them starts off with data?! The class definition begins like so: class BattleIntentionAction(...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
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 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.