تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[سؤال] مشكلة ال Reader
#11
اخت منى 
هذا مثال لطريقة الاتصال بـSQL فقط اضيفي  Database جديدة , وليكن اسمها  TestDatabase

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


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

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

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

هذا الكود 


كود :
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
الرد }}}
تم الشكر بواسطة: الضمير المستتر
#17
هل يوجد اضافه على هذا الكود لكي يظهرلي نتيجة اي بحث اريد ؟؟

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


كود :
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
الرد }}}
تم الشكر بواسطة: الضمير المستتر
#18
رجعنالكم مع بعض الاخطاء ياريت تصحيح منكم 

وين الخطأ ؟؟ 



كود :
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
الرد }}}
تم الشكر بواسطة: الضمير المستتر
#19
السلام عليكم
اخت منى جربي هذه الطريقة

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 
الرد }}}
تم الشكر بواسطة: الضمير المستتر
#20
للأسف بس ما اشتغل الكود 

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

عنجد تعقدت !!!
الرد }}}
تم الشكر بواسطة: الضمير المستتر



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


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم