TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
guray uysal
NA
4
0
Data transfer between different servers
Sep 6 2011 11:48 AM
SqlCommand cmd = new SqlCommand("SELECT (DEPOFISID+20000)*-1 AS DEPOFISID,[TARIH],'ELEKTRA' AS [YETKILI],[ISLEM],[ENO],'BEACH AKTARIM' AS [ACIKLAMA],[GDEPOID],[CDEPOID],[TADET],[TTUTAR],[GSKODU],[CSKODU],[URUNFISID],[URETILDI],[LOGOAKTAR],[LOGODANGELDI],[ISLEMDETAY],[SDEPART],[ONAY],[MUHFISID],[DURUMU],[SUBEID],[EK1],[EK2],[USERID],[DURUM],[MUHFC] FROM DEPOFIS WHERE 1=1 AND '" + string.Format("{0:MM/dd/yyyy}", islema_batarih.EditValue) + "'<=TARIH AND '" + string.Format("{0:MM/dd/yyyy}", islema_bitarih.EditValue) + "'>=TARIH", DBCONNECTION.Sql_Connection.DB_CONNECTB());
SqlCommand cmd_isl = new SqlCommand("SELECT [DEPOFISISLID],(DEPOFISID+20000)*-1 AS DEPOFISID,[STOKID],[MIKTAR],[FBIRIM],[FMIKTAR],[BFIYAT],[SFIYAT],[YETKILI],[ACIKLAMA],[MARKAID],[ISLREFID],[FBFIYAT],[URETSEVIYE],[SATINALMAISLID],[BARKOD],[SKTARIHI],[RGDEPOID],[RCDEPOID],[SARFDEPOID] FROM DEPOFISISL WHERE 1=1 AND DEPOFISID IN(SELECT DEPOFISID FROM DEPOFIS WHERE 1=1 AND '" + string.Format("{0:MM/dd/yyyy}", islema_batarih.EditValue) + "'<=TARIH AND '" + string.Format("{0:MM/dd/yyyy}", islema_bitarih.EditValue) + "'>=TARIH)", DBCONNECTION.Sql_Connection.DB_CONNECTB());
//Transaction Kontrol Islemini Baslat
cmd.Transaction = trans;
cmd_isl.Transaction = trans_isl;
trans = DBCONNECTION.Sql_Connection.DB_CONNECTB().BeginTransaction();
trans_isl = DBCONNECTION.Sql_Connection.DB_CONNECTB().BeginTransaction();
SqlDataReader reader = cmd.ExecuteReader(); >>>>>>>>>>ERROR LINE
SqlBulkCopy copydata = new SqlBulkCopy(DBCONNECTION.Sql_Connection.DB_CONNECTM());
SqlDataReader reader_isl = cmd_isl.ExecuteReader();
SqlBulkCopy copydata_isl = new SqlBulkCopy(DBCONNECTION.Sql_Connection.DB_CONNECTM());
copydata.DestinationTableName = "DEPOFIS";
copydata.NotifyAfter = 500;
copydata.WriteToServer(reader);
copydata_isl.DestinationTableName = "DEPOFISISL";
copydata.NotifyAfter = 500;
copydata_isl.WriteToServer(reader_isl);
//Transaction Kontrol Noktasi Olustur
trans.Save("Start");
trans_isl.Save("Start");
copydata.Close();
copydata_isl.Close();
Above code part is under a button click event.It works correctly.But When I changed the date parameter and click second time on button I get this error "The transaction is either not associated with the current connection or has been completed." Error line shown >>>>>>>> above.What should I do? Thanks for your helps...
Reply
Answers (
3
)
Batch file commands in c#
Switch between panels as if they are tabs in C#