Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
OK guys. I need your help. I have a program in c# in VS that runs a mainform. That mainform exports data to an SQL Database with stored procedures into tables. The data exported is a lot of data (600,000 + rows). I have a problem tho. On my mainform I need to have a "database write out interval". This is a number of how many "rows" will be imported into the database. My problem is however the steps on how to implement that interval. The mainform runs, and when the main program is done, the sql still takes IN data for another 5-10 minutes. Therefore, if I close the mainform, the rest of the data will not me imported. Do you professional programmers out there know a way where I can somehow communicate with SQL to only export data for a user-specified interval. This has to be done with my c# class. I dont know where to begin. I dont think a timer would be a good idea because differenct computers and cpu's perform differently. Any advice would be appreciated.
Posted

So don't allow the main form (or application) to close until the process is complete. You could also display some sort of progress meter/bar that informs the user that there is still quite a way to go. I'm sure others can come up with different answers as well but that should get you going.
 
Share this answer
 
thanks for the response. But my issue is a bit complicated here. The mainform will have other uses for the user while the data is being exported to the database. What I need is: the user puts in "I want 50k rows". I need so that once 50k rows are executed, the database connection from my c# class closes after all the data is exported. Sorry for the confusion.
 
Share this answer
 
Comments
R. Giskard Reventlov 29-Jun-10 11:20am    
Please don't reply with an answer: use comments or 'improve' (alter) your original question.

Perhaps you could offload the processing to the database and only fire it off from the form; thereby ensuring that, even if the form closes, the data import will continue.
Tom Hangler 29-Jun-10 11:55am    
how can i do that? what do you exactly mean by offload?
R. Giskard Reventlov 29-Jun-10 14:05pm    
I mean get the database to do all of the work through a stored procedure. You should be able pass the sp sufficient info to allow it to access the data and import it. That way the form does nothing but trigger the sp and you dont care since the sp is doing the work, not the application.
Tom Hangler 29-Jun-10 14:23pm    
thats wt I have now. The stored procedure does all my work. Is there anything in sql though that will communicate with my c# method to stop the database communication once the user specified number hits the number that they want the database export to stop?
R. Giskard Reventlov 30-Jun-10 3:29am    
Can't you pass the number to the sp and then maybe use 'select top n form foo...' to get the records to work on? That way the application doesn't need to know anything: it is just the trigger. Course you need to take care of any exceptions, etc and best to use a transaction so you can roll back. The sp could notify the user if it goes wrong.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900