Advice needed for finding matches

F

Freddie

I need to perform a validation process from my forms and am not sure how to
accomplish this. I'm new to vb.net. Here is my scenario. In my database I
have a table, we'll call it Table A. In this table there are two fields,
field 1 and field 2. The combination of these two fields will form my unique
index. On my form I have two text boxes. When the user enters data into the
boxes, I need a way to compare the concatenation on the two text box values
to the fields in my table. I thought of possible using a DataSet and
DataTable, possibly looping through it, such as you would a Recordset.
Again I'm new and would appreciate any advice to get pointed in the right
direction.



Kind of what I had in mind, but am open for suggestions.

Ex. How can this be done in vb.net

With rs

Str = rs!field1 &,& rs!field2

If str = text1 &,& text2 then

Match found

End if

.movenxt

end with



Thanks.

Fred
 
A

Armin Zingler

Freddie said:
I need to perform a validation process from my forms and am not sure
how to accomplish this. I'm new to vb.net. Here is my scenario. In my
database I have a table, we'll call it Table A. In this table there
are two fields, field 1 and field 2. The combination of these two
fields will form my unique index. On my form I have two text boxes.
When the user enters data into the boxes, I need a way to compare the
concatenation on the two text box values to the fields in my table. I
thought of possible using a DataSet and DataTable, possibly looping
through it, such as you would a Recordset. Again I'm new and would
appreciate any advice to get pointed in the right direction.

Assuming the fields have been set as the primary key:
DataTable1.Rows.Find(New object(){Value1, value2)
 
F

Freddie

Niether field is a primary key, only a combination of the two fields make up
the uunique index.

Thanks,

Fred
 
C

Cor

Hi Freddie,

You can use something as
\\\
dim myselectedrows as datarow() = ds.tables(0).select("Your
Datacolumn.Expression")
////
This gives back a array of datarows which you can do in a for each loop

or exactly what you ask
dim i as integer
for i = 0 to ds.tables(0).rows.count-1
if ds.tables(0).rows(i).item("Item1")=Item1 AndAlso
................
next
///
And for the movenext
\\\
for i = i to ds.tables(0).rows.count-1
etc.
///
I hope this helps,

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top