تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
مساعدة كود استخراج بيانات من قاعدة بيانات sql
#1
السلام عليكم ورحمة الله وبركاته

اخواني انا عندي كود استخراج بيانات من قاعدة بيانات SQL وهو يستخرج ،، لكن لمره وحده فقط ،،،
يعني استخرج المره الاولى لا يظهر خطا وعند استخراجي ب ID ثاني تظهر مشكلة ،، انا حاوت اتآكد انه تم قفل الامر ،، ولاحظت انه يقفل الامر السابق ،،
لكن المشكلة هي فالامر الاول للاستخراج لا يقفل ،،، هذا كود الاستخراج

كود :
Dim cm As New SqlDataAdapter("select * from Table1 where ID=" & Val(ListView1.SelectedItems(0).Text) & "", Conn)
        Dim ds As New DataSet
        ds.Clear()

        TextBox1.[color=#FF0000]DataBindings.Clear[/color]()
        TextBox2.DataBindings.Clear()
        TextBox7.DataBindings.Clear()
        DateTimePicker8.DataBindings.Clear()
        TextBox45.DataBindings.Clear()
        TextBox46.DataBindings.Clear()
        TextBox47.DataBindings.Clear()
        TextBox4.DataBindings.Clear()
        TextBox5.DataBindings.Clear()
        TextBox6.DataBindings.Clear()
        TextBox3.DataBindings.Clear()
        TextBox71.DataBindings.Clear()
        ComboBox1.DataBindings.Clear()
        ComboBox4.DataBindings.Clear()
        TextBox20.DataBindings.Clear()
        TextBox21.DataBindings.Clear()
        TextBox87.DataBindings.Clear()
        ComboBox2.DataBindings.Clear()
        ComboBox5.DataBindings.Clear()
        TextBox22.DataBindings.Clear()
        TextBox23.DataBindings.Clear()
        TextBox88.DataBindings.Clear()
        ComboBox3.DataBindings.Clear()
        ComboBox6.DataBindings.Clear()
        TextBox20.DataBindings.Clear()
        TextBox21.DataBindings.Clear()
        TextBox87.DataBindings.Clear()
        TextBox22.DataBindings.Clear()
        TextBox23.DataBindings.Clear()
        TextBox88.DataBindings.Clear()
        TextBox24.DataBindings.Clear()
        TextBox25.DataBindings.Clear()
        TextBox89.DataBindings.Clear()
        TextBox24.DataBindings.Clear()
        TextBox25.DataBindings.Clear()
        TextBox89.DataBindings.Clear()
        TextBox26.DataBindings.Clear()
        TextBox27.DataBindings.Clear()
        TextBox28.DataBindings.Clear()
        TextBox29.DataBindings.Clear()
        TextBox30.DataBindings.Clear()
        TextBox37.DataBindings.Clear()
        TextBox39.DataBindings.Clear()
        TextBox40.DataBindings.Clear()
        TextBox41.DataBindings.Clear()
        TextBox42.DataBindings.Clear()
        TextBox43.DataBindings.Clear()
        TextBox38.DataBindings.Clear()



        PictureBox2.DataBindings.Clear()
        PictureBox3.DataBindings.Clear()
        PictureBox4.DataBindings.Clear()
        PictureBox5.DataBindings.Clear()
        PictureBox6.DataBindings.Clear()
        PictureBox7.DataBindings.Clear()
        PictureBox8.DataBindings.Clear()
        PictureBox9.DataBindings.Clear()
        PictureBox10.DataBindings.Clear()
        PictureBox11.DataBindings.Clear()
        PictureBox12.DataBindings.Clear()
        PictureBox13.DataBindings.Clear()

        cm.Fill(ds, "Table1")

        TextBox1.DataBindings.Add("text", ds, "Table1.UserName")
        TextBox2.DataBindings.Add("text", ds, "Table1.MobileNumber")
        TextBox7.DataBindings.Add("text", ds, "Table1.Date", True)
        DateTimePicker8.DataBindings.Add("text", ds, "Table1.DateGiveDress", True)
        TextBox45.DataBindings.Add("text", ds, "Table1.Price")
        TextBox46.DataBindings.Add("text", ds, "Table1.Rest")
        TextBox47.DataBindings.Add("text", ds, "Table1.Recipient")
        TextBox4.DataBindings.Add("text", ds, "Table1.NameShop")
        TextBox5.DataBindings.Add("text", ds, "Table1.PlaceShop")
        TextBox6.DataBindings.Add("text", ds, "Table1.UserShop")
        TextBox3.DataBindings.Add("text", ds, "Table1.Email")
        TextBox71.DataBindings.Add("text", ds, "Table1.NumberDresses")
        ComboBox1.DataBindings.Add("text", ds, "Table1.TypeDesign1")
        ComboBox4.DataBindings.Add("text", ds, "Table1.TypePocket1")
        TextBox20.DataBindings.Add("text", ds, "Table1.IDCloth1")
        TextBox21.DataBindings.Add("text", ds, "Table1.LengthM1")
        TextBox87.DataBindings.Add("text", ds, "Table1.LengthY1")
        ComboBox2.DataBindings.Add("text", ds, "Table1.TypeDesign2")
        ComboBox5.DataBindings.Add("text", ds, "Table1.TypePocket2")
        TextBox22.DataBindings.Add("text", ds, "Table1.IDCloth2")
        TextBox23.DataBindings.Add("text", ds, "Table1.LengthM2")
        TextBox88.DataBindings.Add("text", ds, "Table1.LengthY2")
        ComboBox3.DataBindings.Add("text", ds, "Table1.TypeDesign3")
        ComboBox6.DataBindings.Add("text", ds, "Table1.TypePocket3")
        TextBox24.DataBindings.Add("text", ds, "Table1.IDCloth3")
        TextBox25.DataBindings.Add("text", ds, "Table1.LengthM3")
        TextBox89.DataBindings.Add("text", ds, "Table1.LengthY3")
        TextBox26.DataBindings.Add("text", ds, "Table1.LengthDress")
        TextBox27.DataBindings.Add("text", ds, "Table1.DisplayKtf")
        TextBox28.DataBindings.Add("text", ds, "Table1.DisplayDress")
        TextBox29.DataBindings.Add("text", ds, "Table1.LengthKmSadh")
        TextBox30.DataBindings.Add("text", ds, "Table1.LengthKmKbk")
        TextBox37.DataBindings.Add("text", ds, "Table1.RakbhKllab1")
        TextBox39.DataBindings.Add("text", ds, "Table1.RakbhKllab2")
        TextBox40.DataBindings.Add("text", ds, "Table1.RakbhSadh1")
        TextBox41.DataBindings.Add("text", ds, "Table1.RakbhSadh2")
        TextBox42.DataBindings.Add("text", ds, "Table1.DownDress1")
        TextBox43.DataBindings.Add("text", ds, "Table1.DownDress2")
        TextBox38.DataBindings.Add("text", ds, "Table1.Other")


        PictureBox2.DataBindings.Add("image", ds, "Table1.Img1U1", True)
        PictureBox3.DataBindings.Add("image", ds, "Table1.Img2U1", True)
        PictureBox4.DataBindings.Add("image", ds, "Table1.Img3U1", True)
        PictureBox5.DataBindings.Add("image", ds, "Table1.Img4U1", True)
        '
        PictureBox6.DataBindings.Add("image", ds, "Table1.Img1U2", True)
        PictureBox7.DataBindings.Add("image", ds, "Table1.Img2U2", True)
        PictureBox8.DataBindings.Add("image", ds, "Table1.Img3U2", True)
        PictureBox9.DataBindings.Add("image", ds, "Table1.Img4U2", True)
        '
        PictureBox10.DataBindings.Add("image", ds, "Table1.Img1U3", True)
        PictureBox11.DataBindings.Add("image", ds, "Table1.Img2U3", True)
        PictureBox12.DataBindings.Add("image", ds, "Table1.Img3U3", True)
        PictureBox13.DataBindings.Add("image", ds, "Table1.Img4U3", True)



        TextBox20.ReadOnly = True
        TextBox21.ReadOnly = True
        TextBox87.ReadOnly = True
        '
        TextBox22.ReadOnly = True
        TextBox23.ReadOnly = True
        TextBox88.ReadOnly = True
        '
        TextBox24.ReadOnly = True
        TextBox25.ReadOnly = True
        TextBox89.ReadOnly = True

[COLOR="#FF0000"]       cm.Dispose()
        Conn.Dispose()
        ds.Dispose()
        DataBindings.Clear()
[/COLOR]



هذه صورة المشكلة http://vb4arb.com/vb/uploaded/521_01364922855.png

الرد }}}
تم الشكر بواسطة:
#2
up up up up
الرد }}}
تم الشكر بواسطة:
#3
رتب كالتالي :
cmd.Dispose
Ds.Dispose
Databindings.Clear
Conn.Dispose
(وَقُل رَّبِّ زِدْنِي عِلْمًا)

الرد }}}
تم الشكر بواسطة:
#4
kslawy كتب :رتب كالتالي :
cmd.Dispose
Ds.Dispose
Databindings.Clear
Conn.Dispose

لم تحل المشكلة :confused:

هذه صورة المشكلة http://vb4arb.com/vb/uploaded/521_01364922855.png
الرد }}}
تم الشكر بواسطة:
#5
الصورة ليس بها نص المشكلة
المطلوب نص رسالة الخطأ
(وَقُل رَّبِّ زِدْنِي عِلْمًا)

الرد }}}
تم الشكر بواسطة:
#6
آخر صورة تعني لم يتم تهيئة اتصال.
اللهم إني أعوذ بك من غلبة الدين وغلبة العدو، اللهم إني أعوذ بك من جهد البلاء ومن درك الشقاء ومن سوء القضاء ومن شماتة الأعداء
اللهم اغفر لي خطيئتي وجهلي، وإسرافي في أمري وما أنت أعلم به مني، اللهم اغفر لي ما قدمت وما أخرت، وما أسررت وما أعلنت وما أنت أعلم به مني، أنت المقدم وأنت المؤخر وأنت على كل شيء قدير
الرد }}}
تم الشكر بواسطة:
#7
شكرا لكم يا اخوان ،، المشكلة كانت سخيفة ،،، لكن مستغرب منها انها كانت السبب مع ان اخ امجد
قال لي خذها قاعدة في مجال البرمجة انك تقفل كل امر وتقتله عند الانتهاء منه ،، وانا كاتب في كود قفل العملية في الكود السابق هذا الكود

كود :
cm.Dispose()
       [color=#FF0000] Conn.Dispose()[/color]
        ds.Dispose()
        DataBindings.Clear()

ولكن عند ازالتي لهذا الامر من الكود السابق ،، ذهبت المشكلة

كود :
Conn.Dispose()
الرد }}}
تم الشكر بواسطة:
#8

السلام عليكم ورحمة الله وبركاته


shado1796 كتب :
[b]شكرا لكم يا اخوان ،، المشكلة كانت سخيفة ،،، لكن مستغرب منها انها كانت السبب مع ان اخ امجد
قال لي خذها قاعدة في مجال البرمجة انك تقفل كل امر وتقتله عند الانتهاء منه ،، وانا كاتب في كود قفل العملية في الكود السابق هذا الكود

كود :
cm.Dispose()
       [color=#FF0000] Conn.Dispose()[/color]
        ds.Dispose()
        DataBindings.Clear()

ولكن عند ازالتي لهذا الامر من الكود السابق ،، ذهبت المشكلة

كود :
Conn.Dispose()



كلام الأخ امجد سليم لو كان التعريف عن المتغيرات مثل comm و com وغيرها على مستوى الاجراء وليس على مستوى الكلاس

ولكنك عرفت conn على مستوى الكلاس ولا يجب (قتله).





[/b]

السلام عليكم ورحمة الله وبركاته
الرد }}}
تم الشكر بواسطة:



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


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