منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
[سؤال] مشكلة ال Reader - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : قسم لغة الفيجوال بيسك VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=182)
+--- قسم : قسم اسئلة VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=183)
+--- الموضوع : [سؤال] مشكلة ال Reader (/showthread.php?tid=13876)

الصفحات: 1 2 3


RE: مشكلة ال Reader - HASAN6.0 - 21-11-15

اخت منى 
هذا مثال لطريقة الاتصال بـSQL فقط اضيفي  Database جديدة , وليكن اسمها  TestDatabase

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


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

لاحظي ان جملة الاتصال بالسيرفر لمرة واحدة طول فترة تشغيل البرنامج . ولا داعي لاعادة كتابتها مرات عدة . Shy


RE: مشكلة ال Reader - mona626 - 21-11-15

[url=http://www.up-00.com/][/url]


RE: مشكلة ال Reader - HASAN6.0 - 21-11-15

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


RE: مشكلة ال Reader - mona626 - 21-11-15

للاسف نفس المشكلة 

There is already an open DataReader associated with this Command which must be closed first.


RE: مشكلة ال Reader - HASAN6.0 - 21-11-15

ارفعي مشروع به فورم واحد فقط . وفيه المشكله .


RE: مشكلة ال Reader - mona626 - 21-11-15

تقريبا وجدت الحل بس بيعطيني نتيجة اول بحث فقط 

هذا الكود 


كود :
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



RE: مشكلة ال Reader - mona626 - 22-11-15

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

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


كود :
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



RE: مشكلة ال Reader - mona626 - 22-11-15

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

وين الخطأ ؟؟ 



كود :
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



RE: مشكلة ال Reader - Adrees - 22-11-15

السلام عليكم
اخت منى جربي هذه الطريقة

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 



RE: مشكلة ال Reader - mona626 - 22-11-15

للأسف بس ما اشتغل الكود 

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

عنجد تعقدت !!!