Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# SQL ODBC command
Dear Friends,
 
I had one issue in C# windows application.
 
Here i am working with C# windows applications.
 
My question like, i have one form with two buttons submit & cancel
 
In button click i am staring one thread.
 
The thread contains one stored procedure having the below code part, here it will select bulk information from the .csv file and loading in to the server project folder with the temp_"user specified file name.csv".
 
when process compleats we are copieng temp_"user specified file name.csv" information to the "user specified file name.csv" and finally we are removing the temp_"user specified file name.csv" from the server folder. its working fine.
 
exec master..xp_cmdshell ''bcp "select ''''Column1'''',''''Column2'''',''''Column3'''',''''Column4'''',''''Column4'''',''''Column5'''',''''Column6'''',''''Column7'''',''''Column8''''" queryout "' + @Parent_Folder + @Transformed_Tbl + '.csv" -c -t, -T -Slocalhost'''
 
exec master..xp_cmdshell ''bcp Databasename..' + @database table+ ' out "' + @serverfolder+ 'temp_' + @user specified file name + '.csv" -c -t, -T -Slocalhost'''
 
exec master..xp_cmdshell ''copy /b "' + @serverfolder+ @user specified file name + '.csv" + "' + @serverfolder+ 'temp_' + @user specified file name + '.csv" "' + @serverfolder + @user specified file name+ '.csv"'''
Its running perfectly,But at the time of process running when i hit the cancel button,here i am aborting the running thread and deleting the "temp_user specified file name.csv" & "user specified file name.csv"from the folder and updating the databse.
 
Its aborting and closing all the sql sessions and updating the database but its not deleting the file "temp_user specified file name.csv",why because in the server folder still bcp process still running and sql server having an one alive session.
 
if i close the application even bcp process still running.
 
How to close the bcp.exe session when cancel button click.
 
kindly let me know the solution an urgent basis..
Posted 1-Jul-12 21:15pm
Edited 17-Jul-12 21:53pm
v25
Comments
GanesanSenthilvel at 2-Jul-12 6:21am
   
SQL format
kishore doni at 13-Jul-12 5:06am
   
Dear GanesanSenthilvel,
 
can you please explain it
kishore doni at 23-Jul-12 1:47am
   
Kindly let me know how get the particular bcp process id while using concurrent users.
kishore doni at 13-Jul-12 3:39am
   
Dear GanesanSenthilvel,
 
can you please explain it

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

It is more a suggestion, Try to fetch the processid for your process
using System.Daignostic;
and terminate that process on your cancle button click event.
  Permalink  
Comments
kishore doni at 2-Jul-12 6:48am
   
Dear sinhasourabh,
 
Thanks for your reply,
you mean that i need to fetch process of my applcation process id or stored procedure process id.
i tried fetch my application process id, entire applicaion is closing.
how to get the running bcp process id. Kindly let me know
kishore doni at 2-Jul-12 7:23am
   
Dear sinhasourabh,
 
Thanks for your reply,
you mean that i need to fetch process of my applcation process id or stored procedure process id.
i tried fetch my application process id, entire applicaion is closing.
how to get the running bcp process id. Kindly let me know
Enter your reply below and click the Submit button.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 299
1 Maciej Los 295
2 Sergey Alexandrovich Kryukov 205
3 Aajmot Sk 202
4 Sinisa Hajnal 166
0 OriginalGriff 7,760
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,785


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 23 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100