02-10-13, 04:35 PM
السلام عليكم و رحمة الله و بركاته
السلام عليكم و رحمة الله و بركاته
كود :
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Dim sqlSearch As String
If txtName1.Text <> "" And txtName2.Text.Trim <> "" And txtName3.Text.Trim = "" Then
sqlSearch = "Select * from MyTable where Name1 like '" & txtName1.Text & "' and Name2 like '" & txtName2.Text & "'"
ElseIf txtName1.Text <> "" And txtName2.Text.Trim = "" And txtName3.Text.Trim <> "" Then
sqlSearch = "Select * from MyTable where Name1 like '" & txtName1.Text & "' and Name3 like '" & txtName3.Text & "'"
ElseIf txtName1.Text = "" And txtName2.Text.Trim <> "" And txtName3.Text.Trim <> "" Then
sqlSearch = "Select * from MyTable where Name2 like '" & txtName2.Text & "' and Name3 like '" & txtName3.Text & "'"
ElseIf txtName1.Text <> "" And txtName2.Text.Trim <> "" And txtName3.Text.Trim <> "" Then
sqlSearch = "Select * from MyTable where Name1 like '" & txtName1.Text & "' and Name2 like '" & txtName2.Text & "' and Name3 like '" & txtName3.Text & "'"
ElseIf txtName1.Text <> "" And txtName2.Text.Trim = "" And txtName3.Text.Trim = "" Then
sqlSearch = "Select * from MyTable where Name1 like '" & txtName1.Text & "'"
ElseIf txtName1.Text = "" And txtName2.Text.Trim <> "" And txtName3.Text.Trim = "" Then
sqlSearch = "Select * from MyTable where Name2 like '" & txtName2.Text & "'"
ElseIf txtName1.Text = "" And txtName2.Text.Trim = "" And txtName3.Text.Trim <> "" Then
sqlSearch = "Select * from MyTable where Name1 Name3 like '" & txtName3.Text & "'"
Else
MsgBox("فضلا إملأ على الأقل اسم واحد", MsgBoxStyle.Information, "خطأ")
Exit Sub
End If
End Subالسلام عليكم و رحمة الله و بركاته
