الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

ما الخطأ في هذا الكود

بدأه علاء عبدالخالق في 8 يناير 2009 · 3 رد · 551 مشاهدة · في Microsoft Visual Basic.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

بســم الله الـرحمــن الرحيــم

SQL = "select employe_no from table1 "

con.Open()

cmd.Connection = con

cmd.CommandType = CommandType.Text

cmd.CommandText = SQL

dr = cmd.ExecuteReader

Do While dr.Read

SQL = "insert into table2 (employe_no)values (,'" & dr.Item("employe_no) & "')"

cmd.Connection = con

cmd.CommandType = CommandType.Text

cmd.CommandText = SQL

cmd.ExecuteNonQuery()

Loop

dr.Close()

Close_Con()

يعطي الرسالة الخاطئة التالية

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

#2

مرحباً أخي الكريم .

حاول نسخ المعلومات الى مصفوفة ومن ثم ادخلهم الى الـ Table .

_______________________

الرسالة تقول :

هناك DataReader مقتوح مرتبط بهذا Command الذي يجب أن يكون مغلق أولاً .

تم تعديل هذه المشاركة بواسطة Bashar Rabat في 8 يناير 2009 في 21:11

The important thing is not so much

that every child should be taught,

as that every child should be given the wish to learn.

#3

جرب التالي :

 

SQL [color= #339933;]= [color= #0000ff;]"select employe_no from table1 "

Con[color= #339933;].Open[color= #009900;]([color= #009900;])

CMD[color= #339933;].Connection [color= #339933;]= Con

CMD[color= #339933;].CommandType [color= #339933;]= CommandType[color= #339933;].Text

CMD[color= #339933;].CommandText [color= #339933;]= SQL

DR [color= #339933;]= CMD[color= #339933;].ExecuteReader

[color= #b1b100;]Do [color= #b1b100;]While DR[color= #339933;].Read

 Dim CMD2 [color= #b1b100;]As [color= #000000; font-weight: bold;]New SqlCommand[color= #009900;]([color= #0000ff;]"insert into table2 (employe_no)values (,'" [color= #339933;]& dr[color= #339933;].Item[color= #009900;]([color= #0000ff;]"employe_no) 
& "[color= #0000ff;]')"

[color= #0000ff;]CMD2 .Connection = Con

[color= #0000ff;]CMD2 .ExecuteNonQuery()

[color= #0000ff;]Loop

[color= #0000ff;]DR.Close()

[color= #0000ff;]Close.Con()

The important thing is not so much

that every child should be taught,

as that every child should be given the wish to learn.

#4

شكراً يا أخي وجزاك الله كل خير وأسف على تأخير الرد لكن النيت كان فاصل عندي شكراً

مواضيع مشابهة