منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : زر البحث في الفيجول بيسك
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
رومنس الشوق;6407715 كتب :
السلام عليكم 

انا عندي 2 ازرار للبحث الاول البحث برقم الهويه والاخر بالاسم 

انا ابي اخلى زر البحث زر واحد فقط بدل 2 ازرار 

هذا كود البحث بالاسم


كود :
conn.Open()
        Try
            Dim cmdselect As New OleDbCommand
            cmdselect.Connection = conn
            cmdselect.CommandText = " select * from doctor where D_Name = '" + txtname.Text + "' "
            Dim re As OleDbDataReader
            re = cmdselect.ExecuteReader
            If re.Read Then
                txtid.Text = re(0).ToString
                txtname.Text = re(1).ToString
                txtnumq.Text = re(2).ToString
                txtnamef.Text = re(3).ToString
                txtnumbert.Text = re(4).ToString
                txtdata.Text = re(5).ToString
                txtnumkf.Text = re(6).ToString
            Else
                MsgBox("بيانات الشخص غير موجوده قم باضافتها")
                txtid.Clear()
                txtname.Clear()
                txtnamef.Clear()
                txtnumbert.Clear()
                txtnumkf.Clear()
                txtnumq.Clear()
                txtdata.Clear()
            End If
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        End Try

        conn.Close()
    End Sub


وهذا زر البحث برقم الهويه


كود :
conn.Open()
        Try
            Dim cmdselect As New OleDbCommand
            cmdselect.Connection = conn
            cmdselect.CommandText = " select * from doctor where doc_ID = '" + txtid.Text + "' "
            Dim re As OleDbDataReader
            re = cmdselect.ExecuteReader
            If re.Read Then
                txtid.Text = re(0).ToString
                txtname.Text = re(1).ToString
                txtnumq.Text = re(2).ToString
                txtnamef.Text = re(3).ToString
                txtnumbert.Text = re(4).ToString
                txtdata.Text = re(5).ToString
                txtnumkf.Text = re(6).ToString
            Else
                MsgBox("بيانات الشخص غير موجوده قم باضافتها")
                txtid.Clear()
                txtname.Clear()
                txtnamef.Clear()
                txtnumbert.Clear()
                txtnumkf.Clear()
                txtnumq.Clear()
                txtdata.Clear()
            End If
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        End Try

        conn.Close()
    End Sub


شاكر ومقدر لكم
اخب الفاضل :

بدلا من عمل 2 زر للبحث يتم عمل البحث من خلال زر واحد بمعلومية اختيار بين 2 Option
جرب بالطريقة التالية 

PHP كود :
conn.Open()
 
       Try
            Dim cmdselect 
As New OleDbCommand
            cmdselect
.Connection conn
            cmdselect
.CommandText " select * from doctor where doc_ID = '" txtid.Text "' OR D_Name = '" txtname.Text "' "
 
           Dim re As OleDbDataReader
            re 
cmdselect.ExecuteReader
            If re
.Read Then
                txtid
.Text re(0).ToString
                txtname
.Text re(1).ToString
                txtnumq
.Text re(2).ToString
                txtnamef
.Text re(3).ToString
                txtnumbert
.Text re(4).ToString
                txtdata
.Text re(5).ToString
                txtnumkf
.Text re(6).ToString
            Else
                MsgBox
("بيانات الشخص غير موجوده قم باضافتها")
 
               txtid.Clear()
 
               txtname.Clear()
 
               txtnamef.Clear()
 
               txtnumbert.Clear()
 
               txtnumkf.Clear()
 
               txtnumq.Clear()
 
               txtdata.Clear()
 
           End If
 
       Catch ex As Exception
            MsgBox
(ex.Message.ToString)
 
       End Try

 
       conn.Close()
 
   End Sub 
السلام عليكم
كود بحث بدون كثرة ازرار

كود :
conn.Open()
        Try
            Dim cmdselect As New OleDbCommand
            cmdselect.Connection = conn
           dim kk as string



 if txtname.text <> "" then   kk= " select * from doctor where D_Name = '" + txtname.Text + "'"
if isnumeric(txtid.text) then   kk= " select * from doctor where doc_ID = " + txtid.Text


cmdselect.CommandText = kk
            Dim re As OleDbDataReader
            re = cmdselect.ExecuteReader
            If re.Read Then
                txtid.Text = re(0).ToString
                txtname.Text = re(1).ToString
                txtnumq.Text = re(2).ToString
                txtnamef.Text = re(3).ToString
                txtnumbert.Text = re(4).ToString
                txtdata.Text = re(5).ToString
                txtnumkf.Text = re(6).ToString
            Else
                MsgBox("بيانات الشخص غير موجوده قم باضافتها")
                txtid.Clear()
                txtname.Clear()
                txtnamef.Clear()
                txtnumbert.Clear()
                txtnumkf.Clear()
                txtnumq.Clear()
                txtdata.Clear()
            End If
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        End Try

        conn.Close()
    End Sub
(29-01-16, 04:04 PM)رومنس الشوق كتب : [ -> ]
رومنس الشوق;6407715 كتب :
السلام عليكم 

انا عندي 2 ازرار للبحث الاول البحث برقم الهويه والاخر بالاسم 

انا ابي اخلى زر البحث زر واحد فقط بدل 2 ازرار 

هذا كود البحث بالاسم


كود :
conn.Open()
        Try
            Dim cmdselect As New OleDbCommand
            cmdselect.Connection = conn
            cmdselect.CommandText = " select * from doctor where D_Name = '" + txtname.Text + "' "
            Dim re As OleDbDataReader
            re = cmdselect.ExecuteReader
            If re.Read Then
                txtid.Text = re(0).ToString
                txtname.Text = re(1).ToString
                txtnumq.Text = re(2).ToString
                txtnamef.Text = re(3).ToString
                txtnumbert.Text = re(4).ToString
                txtdata.Text = re(5).ToString
                txtnumkf.Text = re(6).ToString
            Else
                MsgBox("بيانات الشخص غير موجوده قم باضافتها")
                txtid.Clear()
                txtname.Clear()
                txtnamef.Clear()
                txtnumbert.Clear()
                txtnumkf.Clear()
                txtnumq.Clear()
                txtdata.Clear()
            End If
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        End Try

        conn.Close()
    End Sub


وهذا زر البحث برقم الهويه


كود :
conn.Open()
        Try
            Dim cmdselect As New OleDbCommand
            cmdselect.Connection = conn
            cmdselect.CommandText = " select * from doctor where doc_ID = '" + txtid.Text + "' "
            Dim re As OleDbDataReader
            re = cmdselect.ExecuteReader
            If re.Read Then
                txtid.Text = re(0).ToString
                txtname.Text = re(1).ToString
                txtnumq.Text = re(2).ToString
                txtnamef.Text = re(3).ToString
                txtnumbert.Text = re(4).ToString
                txtdata.Text = re(5).ToString
                txtnumkf.Text = re(6).ToString
            Else
                MsgBox("بيانات الشخص غير موجوده قم باضافتها")
                txtid.Clear()
                txtname.Clear()
                txtnamef.Clear()
                txtnumbert.Clear()
                txtnumkf.Clear()
                txtnumq.Clear()
                txtdata.Clear()
            End If
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        End Try

        conn.Close()
    End Sub


شاكر ومقدر لكم
شكرا جزيلا