تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[سؤال] مشكلة فى كود البحث فى قواعد بيانات sql
#5
-
استبدل الكود بما يلي وجرب.... (مراجعة ثانية)
كود :
Dim sql As String = " "
Dim where As String = " "

Dim firstcont As Boolean = True
If txtquery1.Text.Trim() <> "" Then
    If firstcont = False Then
        where &= " WHERE [id] LIKE '%" & txtquery1.Text.Trim() & "%'"
    Else
        firstcont = False
        where &= " WHERE [id] LIKE '%" & txtquery1.Text.Trim() & "%'"
    End If

End If

sql = " SELECT * FROM [patient] " & where

Dim da As New SqlDataAdapter(sql , sqlcon)
Dim dt As New DataTable

If da.Fill(dt) > 0 Then
    Dim row As DataRow = dt.Rows(0)
    'txtrec1.Text = row.Item(" id ")
    txtname.Text = row.Item("name")
    txtid.Text = row.Item("id")
    cbojob.SelectedValue = row.Item("jobid")
    txtdate.MyText = row.Item(" date")
    txttel.Text = row.Item("tel ")
    txtphone.Text = row.Item(" phone")
    txtaddress.Text = row.Item(" address")
    txtcomment.Text = row.Item("comments")
Else
    lblerror.BackColor = Color.Red
    lblerror.BackColor = Color.White
    lblerror.Text = "السجل غير موجود "
End If
الرد }}}
تم الشكر بواسطة: عابر سبيل


الردود في هذا الموضوع
RE: مشكلة فى كود البحث فى قواعد بيانات sql - بواسطة vbnet - 04-05-14, 06:19 PM


التنقل السريع :


يقوم بقرائة الموضوع: