hi, i started using VB 2008 recently (with perl background, its a big leap) and having a problem with database.
i am trying to access a database that is attached to a different form. i managed to get my code to work if i was writing on the same form.
example of code that will work just fine
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
For Each row As DataRow In Contact_dataDataSet1.ContactTable.Rows
If row.Item("LastName").Equals("Singer") Then
MessageBox.Show(" name = " & row.Item("FirstName"))
End If
Next
End Sub
however, when i use the same code on another form, nothing happens although there are no errors. what is troubling is that the msgbox for "hello world" did not even show up. i guess there is a syntax error in my for each loop
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
For Each row As DataRow In form2.Contact_dataDataSet1.ContactTable.Rows
MsgBox("hello world!!!")
If row.Item("LastName").Equals("Singer") Then
MessageBox.Show(" name = " & row.Item("FirstName"))
End If
Next
End Sub
in addition to that, suppose i do not want to loop through the whole database to find lastname = singer, how am i able to obtain the firstname or singer? in Perl i would have used hashes. something like print $contacts{"firstname"}{$lastname};