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

search a record

10
hi...i have an application which stores records in a text file. the application loads the records in array of objects when the page is loaded. then, we can add, search, delete the records in array and save the array back to the file. code for inserting new record and then saving it works fine. am havin problem wid searching. search is based on ID.

Expand|Select|Wrap|Line Numbers
  1. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  2.         If Not IsPostBack Then
  3.             Dim d As New Developer
  4.             Dim reader As System.IO.StreamReader
  5.             Dim strInput As String
  6.             If File.Exists(Request.MapPath("developer.txt")) Then
  7.                 reader = System.IO.File.OpenText(MapPath("developer.txt"))
  8.  
  9.                 While reader.Peek <> -1
  10.                     strInput = reader.ReadLine()
  11.                     Dim splitout As String()
  12.                     splitout = Split(strInput, " ")
  13.  
  14.                     d.DeveloperID = splitout(0)
  15.                     d.Name = splitout(1)
  16.                     d.Salary = splitout(2)
  17.                     DeveloperBook.Add(d)
  18.                 End While
  19.                 Session("Developer") = DeveloperBook
  20.             Else
  21.                 MsgBox("File not found")
  22.             End If
  23.         End If
  24.     End Sub
  25.  
  26. Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
  27.         Dim d As New Developer
  28.         Dim DeveloperBook As ArrayList = getSession()
  29.         Dim i As Integer
  30.         For i = 0 To DeveloperBook.Count - 1
  31.             If CType(DeveloperBook(i), Developer).DeveloperID = txtID.Text Then
  32.                 txtName.Text = CType(DeveloperBook(i), Developer).Name
  33.                 txtSalary.Text = CType(DeveloperBook(i), Developer).Salary
  34.                 Exit For
  35.             End If
  36.         Next
  37.         Session("Developer") = DeveloperBook
  38.  
  39.     End Sub
  40.  
  41.  Private Function getSession() As ArrayList
  42.         Return CType(Session("Developer"), ArrayList)
  43.     End Function
Mar 8 '08 #1
2 1004
kenobewan
4,871 Expert 4TB
What is the problem? Do you get an error message? Are you clearing your sessions?
Mar 9 '08 #2
grey15
10
thx....i fixed it....
Mar 9 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: CharitiesOnline | last post by:
Hello, I have set this script up to add paging to a search results page. Which on the first page works fine. I calculates how many pages there should be depending on the number of results returned...
1
by: Jack-of-all-traits | last post by:
This is a big problem and I really need help, no one seems to know how to solve this problem. I want to take the data from a record in a particular a field that contains the names of generic...
9
by: Christopher Koh | last post by:
I will make a form which will search the database (just like google interface) that will look/match for the exact name in the records of a given fieldname. Any suggestions on how to make the code?
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...
7
by: John | last post by:
hi, i have created a search form, and i want to search for a specific item in a field. e.g. i have a field called colour, which has record1 = 'red, blue, green' and another record2 = 'red' ...
3
by: vonclausowitz | last post by:
Hi All, I was thinking of creating a table in my database to index all words in the database. That way I can quickly search for one or more words and the index table will return the words and...
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...
3
by: bluez | last post by:
I want to design a webpage where user can search the data from the database and list out the related records. Each of the record got a delete button which allow user to delete the record. ...
1
by: captainmorgan | last post by:
I have included an unbound field called which is used to quickly move to the desired record, by searching the last name field. I have been using this code for a few years, with only one...
9
by: AMBLY | last post by:
Hello ! Hope someone might be able to help me with this one. I run Access2000 on XP. I have a form : frmONE- which contains a txt field: ctrCTN from my table/database. The values in ctrCTN are...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.