Easy database question

  • Thread starter Thread starter LedZep
  • Start date Start date
L

LedZep

What up,

All I need to do is enter a last name in a text box, query a MSAccess
database and display the name with the corresponding columns. This is
no problem, but when there are more than one records with the same
last name, I need to click a command button to display the next record
with that name. I cant find it in any of my books and it sounds like
an easy enough question. Any help is definately appreciated.

TIA,

LedZep
 
For easy questoin easy answer..:o))

I don't know what is exactly your current code but...I suppose that you are
using datasets
so, you can defiine a variable in the form class (so it will be global for
the form)

- after selecting for a new name set the variable to 1

- in the button
if myVariable < mydataset.tables("tablename").rows.count then
myVariable +=1
display mydataset.tables("tablename").rows (myvariable)
else
msgbox ("last one")
end if
 
What up,

All I need to do is enter a last name in a text box, query a MSAccess
database and display the name with the corresponding columns. This is
no problem, but when there are more than one records with the same
last name, I need to click a command button to display the next record
with that name. I cant find it in any of my books and it sounds like
an easy enough question. Any help is definately appreciated.

TIA,

LedZep

I forgot to mention I'm using vb.Net
 
Hi Led,
This depends really how you fill the textbox with the names.
You can use a reader or a dataset or a dataview etc.
Can you send a piece of code, maybe someone can help you then.
-reading the access file
-filling the textbox
Cor
 
Cor said:
Hi Led,
This depends really how you fill the textbox with the names.
You can use a reader or a dataset or a dataview etc.
Can you send a piece of code, maybe someone can help you then.
-reading the access file
-filling the textbox
Cor

If txtLast.Text <> "" Then
AddressBookDataSet.Clear()
AddressBookDataAdapter.SelectCommand.CommandText = _
"SELECT * FROM addresses WHERE lastname = '" & txtLast.Text
& "' "

AddressBookDataAdapter.Fill(AddressBookDataSet)

Display(AddressBookDataSet)
txtStatus.Text &= vbCrLf & "Query Successful " & _
vbCrLf

Else
txtLast.Text = "Enter last name here then press Find"
End If


When there's two records with the same last name I have to click a
command button to display the next record in the txtLast. Im lost.

Thanks,

LedZep
 
Hi Led.

Your dataset contains a simple table, I think you can reach it with (in a
kind of pseudo code)
\\\\\
dim i as integer
dim adress as string
adress = Addressbookdataset.table(0).rows(i)("adres").tostring
/////
You can to do a for each loop with
\\\
dim dr as datarow
for each dr in addressbookdataset.table(0).rows
adress = dr("adres").tostring
next
///
I hope this helps a little bit?
Cor
 
Back
Top