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

نسخة كاملة : مشكلة ال Reader
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
الصفحات : 1 2 3
اخت منى 
هذا مثال لطريقة الاتصال بـSQL فقط اضيفي  Database جديدة , وليكن اسمها  TestDatabase

وفيها جدول users وبه حقول كما في الصورة 


ثم في الـModule  في المشروع فقط غيري اسم السيرفر او اسم قاعدة البيانات ايضاً .

لاحظي ان جملة الاتصال بالسيرفر لمرة واحدة طول فترة تشغيل البرنامج . ولا داعي لاعادة كتابتها مرات عدة . Shy
[url=http://www.up-00.com/][/url]
ثم في الـModule في المشروع فقط غيري اسم السيرفر او اسم قاعدة البيانات ايضاً .
للاسف نفس المشكلة 

There is already an open DataReader associated with this Command which must be closed first.
ارفعي مشروع به فورم واحد فقط . وفيه المشكله .
تقريبا وجدت الحل بس بيعطيني نتيجة اول بحث فقط 

هذا الكود 


كود :
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
       Dim sqlStr As String = "SELECT * FROM MonitoringReports WHERE EmployeeID = '" & TextBox9.Text & "' and LicensesNumber='" & TextBox1.Text & "'"
       Dim dataAdapter As New SqlDataAdapter(sqlStr, con)
       dataAdapter.Fill(dt)
       TextBox8.Text = CStr(dt.Rows(rowIndex)("EmployeeName"))
       TextBox9.Text = CStr(dt.Rows(rowIndex)("EmployeeID"))
       DateTimePicker2.Value = CStr(dt.Rows(rowIndex)("DateOfEntry"))
       TextBox1.Text = CStr(dt.Rows(rowIndex)("LicensesNumber"))
       TextBox2.Text = CStr(dt.Rows(rowIndex)("LicensesName"))
       TextBox5.Text = CStr(dt.Rows(rowIndex)("LicensesType"))
       ComboBox6.Text = CStr(dt.Rows(rowIndex)("LicensesCase"))
       ComboBox1.Text = CStr(dt.Rows(rowIndex)("Location"))
       ComboBox2.Text = CStr(dt.Rows(rowIndex)("Street"))
       TextBox3.Text = CStr(dt.Rows(rowIndex)("NearOrNextTo"))
       ComboBox3.SelectedValue = CStr(dt.Rows(rowIndex)("ActionType"))
       ComboBox7.SelectedValue = CStr(dt.Rows(rowIndex)("ActionNumber"))
       ComboBox5.SelectedValue = CStr(dt.Rows(rowIndex)("FineOrWarrningType"))
       TextBox4.Text = CStr(dt.Rows(rowIndex)("Notes"))
       DateTimePicker1.Value = CStr(dt.Rows(rowIndex)("DateOfFollow"))

   End Sub
هل يوجد اضافه على هذا الكود لكي يظهرلي نتيجة اي بحث اريد ؟؟

الحمد لله تم إيجاد الحل  : 


كود :
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
       Dim sqlStr As String = "SELECT * FROM MonitoringReports WHERE EmployeeID = '" & TextBox9.Text & "' and LicensesNumber='" & TextBox1.Text & "'"
       Dim dataAdapter As New SqlDataAdapter(sqlStr, con)
       dataAdapter.Fill(dt)

       For i As Integer = 0 To (dt.Rows.Count - 1)
           rowIndex = i
           TextBox8.Text = CStr(dt.Rows(rowIndex)("EmployeeName"))
           TextBox9.Text = CStr(dt.Rows(rowIndex)("EmployeeID"))
           DateTimePicker2.Value = CStr(dt.Rows(rowIndex)("DateOfEntry"))
           TextBox1.Text = CStr(dt.Rows(rowIndex)("LicensesNumber"))
           TextBox2.Text = CStr(dt.Rows(rowIndex)("LicensesName"))
           TextBox5.Text = CStr(dt.Rows(rowIndex)("LicensesType"))
           ComboBox6.Text = CStr(dt.Rows(rowIndex)("LicensesCase"))
           ComboBox1.Text = CStr(dt.Rows(rowIndex)("Location"))
           ComboBox2.Text = CStr(dt.Rows(rowIndex)("Street"))
           TextBox3.Text = CStr(dt.Rows(rowIndex)("NearOrNextTo"))
           ComboBox3.SelectedValue = CStr(dt.Rows(rowIndex)("ActionType"))
           ComboBox7.SelectedValue = CStr(dt.Rows(rowIndex)("ActionNumber"))
           ComboBox5.SelectedValue = CStr(dt.Rows(rowIndex)("FineOrWarrningType"))
           TextBox4.Text = CStr(dt.Rows(rowIndex)("Notes"))
           DateTimePicker1.Value = CStr(dt.Rows(rowIndex)("DateOfFollow"))
       Next

   End Sub
رجعنالكم مع بعض الاخطاء ياريت تصحيح منكم 

وين الخطأ ؟؟ 



كود :
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
       If TextBox1.Text = "" Then
           MsgBox("يــرجــى إدخــال رقــم الــرخــصــة", MsgBoxStyle.Critical, "خـــطـــأ")
           TextBox1.Focus()
           Exit Sub
       End If

       If dt.Rows.Count <> 0 Then
           MsgBox("No records found")
           DateTimePicker2.Value = Now
           TextBox1.Text = ""
           TextBox2.Text = ""
           TextBox5.Text = ""
           ComboBox6.Text = ""
           ComboBox1.Text = ""
           ComboBox2.Text = ""
           TextBox3.Text = ""
           ComboBox3.Text = ""
           ComboBox4.Text = ""
           ComboBox5.Text = ""
           TextBox4.Text = ""
           TextBox7.Text = ""
           ComboBox3.Visible = False
       Else
           Dim sqlStr As String = "SELECT * FROM MonitoringReports WHERE EmployeeID = '" & TextBox9.Text & "' and LicensesNumber='" & TextBox1.Text & "'"
           Dim dataAdapter As New SqlDataAdapter(sqlStr, con)
           dataAdapter.Fill(dt)
           For i As Integer = 0 To (dt.Rows.Count - 1)
               rowIndex = i
               TextBox8.Text = CStr(dt.Rows(rowIndex)("EmployeeName"))
               TextBox9.Text = CStr(dt.Rows(rowIndex)("EmployeeID"))
               DateTimePicker2.Value = CStr(dt.Rows(rowIndex)("DateOfEntry"))
               TextBox1.Text = CStr(dt.Rows(rowIndex)("LicensesNumber"))
               TextBox2.Text = CStr(dt.Rows(rowIndex)("LicensesName"))
               TextBox5.Text = CStr(dt.Rows(rowIndex)("LicensesType"))
               ComboBox6.Text = CStr(dt.Rows(rowIndex)("LicensesCase"))
               ComboBox1.Text = CStr(dt.Rows(rowIndex)("Location"))
               ComboBox2.Text = CStr(dt.Rows(rowIndex)("Street"))
               TextBox3.Text = CStr(dt.Rows(rowIndex)("NearOrNextTo"))
               ComboBox3.SelectedValue = CStr(dt.Rows(rowIndex)("ActionType"))
               ComboBox7.SelectedValue = CStr(dt.Rows(rowIndex)("ActionNumber"))
               ComboBox5.SelectedValue = CStr(dt.Rows(rowIndex)("FineOrWarrningType"))
               TextBox4.Text = CStr(dt.Rows(rowIndex)("Notes"))
               DateTimePicker1.Value = CStr(dt.Rows(rowIndex)("DateOfFollow"))
           Next
       End If
   End Sub
السلام عليكم
اخت منى جربي هذه الطريقة

PHP كود :
       Dim da As New OleDbDataAdapter("Select * from UsersTb where id=" CInt(TextBox1.Text) & " and UserName='" TextBox4.Text "'"cn)

 
       Dim dt As New DataTable
        da
.Fill(dt)

 
       For Each dr As DataRow In dt.Rows
            TextBox2
.Text dr("id").ToString()
 
           TextBox3.Text dr("UserName").ToString()
 
           ComboBox1.SelectedItem dr("UserName").ToString()
 
       Next 
للأسف بس ما اشتغل الكود 

كل الي بريد انه كود للبحث من حقلين + اذا ما لقى نتائج بيعطي رساله "لا بيانات "

عنجد تعقدت !!!
الصفحات : 1 2 3