|
-
April 23rd, 2009, 04:02 AM
#1
Searches by no primary key fields
First of all, ive been reading this forums and it already helped me a lot with my application, im new to visual studio and im currently developing an aplication for my school project in vs 2008.
Im using a simple access database with only 2 tables and I creadted a form with a datagrid to show all data inside the tables, and now i want to create search buttons for each field of the table . like, "seach by Name", Seach by date" etc... i tried to use the simple code
Code:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim cod As String
cod = InputBox("Type the Id to search: ", "Search By ID")
If cod <> " " Then
Dim reg1 As distritos1('dataset).distritoRow = Distritos11.distrito.FindByid_distrito(Convert.ToInt32(cod))
If regi Is Nothing Then
MsgBox("Distrito not Found!!!")
Else
MsgBox(" distrito:" & registo.distrito_name)
End If
Else
MsgBox("Wrong Id!! ", MsgBoxStyle.Exclamation, "Search By Id")
End If
End Sub
My biggest problem now is that this code works very well to search by id (which is my table primary key), but now i want to search by other fields and this code only allows to search by primary key!
Is there any way to use something similar to this code to search by other fields?
Thanks for reading and i hope i can get help!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|