Click here to Skip to main content
15,919,245 members
Home / Discussions / C#
   

C#

 
QuestionSQL1159 Initialization error with DB2 .NET Data Provider, reason code 7 Pin
Tej_dev2-Sep-16 8:02
Tej_dev2-Sep-16 8:02 
AnswerRe: SQL1159 Initialization error with DB2 .NET Data Provider, reason code 7 Pin
NotPolitcallyCorrect2-Sep-16 8:15
NotPolitcallyCorrect2-Sep-16 8:15 
AnswerRe: SQL1159 Initialization error with DB2 .NET Data Provider, reason code 7 Pin
Dave Kreskowiak2-Sep-16 9:17
mveDave Kreskowiak2-Sep-16 9:17 
GeneralRe: SQL1159 Initialization error with DB2 .NET Data Provider, reason code 7 Pin
Tej_dev6-Sep-16 6:47
Tej_dev6-Sep-16 6:47 
GeneralRe: SQL1159 Initialization error with DB2 .NET Data Provider, reason code 7 Pin
Dave Kreskowiak6-Sep-16 9:31
mveDave Kreskowiak6-Sep-16 9:31 
QuestionWhat kind of relation is created with virtual keyword in EF Pin
Tridip Bhattacharjee2-Sep-16 2:46
professionalTridip Bhattacharjee2-Sep-16 2:46 
AnswerRe: What kind of relation is created with virtual keyword in EF Pin
Pete O'Hanlon2-Sep-16 3:10
mvePete O'Hanlon2-Sep-16 3:10 
QuestionOverride properties in derived classes - some have fixed value, some do not Pin
amaturi1-Sep-16 22:32
amaturi1-Sep-16 22:32 
AnswerRe: Override properties in derived classes - some have fixed value, some do not Pin
Pete O'Hanlon1-Sep-16 22:57
mvePete O'Hanlon1-Sep-16 22:57 
AnswerRe: Override properties in derived classes - some have fixed value, some do not Pin
OriginalGriff1-Sep-16 23:13
mveOriginalGriff1-Sep-16 23:13 
GeneralRe: Override properties in derived classes - some have fixed value, some do not Pin
BillWoodruff2-Sep-16 1:49
professionalBillWoodruff2-Sep-16 1:49 
GeneralRe: Override properties in derived classes - some have fixed value, some do not Pin
OriginalGriff2-Sep-16 3:57
mveOriginalGriff2-Sep-16 3:57 
QuestionTimeStamp to PDF Pin
Member 119141971-Sep-16 22:06
Member 119141971-Sep-16 22:06 
QuestionSuggesstions on saving 100s of rowsto the database Pin
Giridhar Aruri1-Sep-16 15:27
Giridhar Aruri1-Sep-16 15:27 
AnswerRe: Suggesstions on saving 100s of rowsto the database Pin
OriginalGriff1-Sep-16 20:22
mveOriginalGriff1-Sep-16 20:22 
AnswerRe: Suggesstions on saving 100s of rowsto the database Pin
Eddy Vluggen1-Sep-16 23:10
professionalEddy Vluggen1-Sep-16 23:10 
QuestionNeed to cancel BackgroundWorker Pin
David_411-Sep-16 13:01
David_411-Sep-16 13:01 
Hello all. I have a background worker that executes a query against an SQL Server database. The user clicks a button and the query runs, then the results of the query go into a datagrid. The users are requesting a Cancel button for the query because the queries can take a very long time to run. So when the user clicks the Run Query button, a small form with a Cancel Button opens. If the user clicks the button, DialogueResult.Cancel is returned and I execute CancelAsync().

Meanwhile, in my DoWork thread, I am preparing to run the query. When I run the query, I execute

adapter3.Fill(GlobalData.g_queryData);

So, there is no loop. Most of the forums I have seen tell you to check Backgroundworker.CancellationPending. The problem is that I am not running in a loop.

So, can someone suggest maybe another approach to canceling a query that is currently running?

Thanks,
David

C#
using (SqlConnection connection = new SqlConnection(GlobalStr.sqlConnStringMetadata))
                {
                    try
                    {
                        connection.Open();

                        /*
                         * DRW 3/10/2016
                         * Added the following Transaction object in order to set the isolation level of all queries
                         * run from MAnDA to to Read Uncommited.
                         */
                        SqlTransaction Transaction = connection.BeginTransaction(IsolationLevel.ReadUncommitted);

                        using (SqlCommand testQuery = new SqlCommand(GlobalStr.previewQueryString, connection))
                        {
                            /*
                             * DRW 3/11/2016
                             * User sets the query timeout value via a textbox on the main form. The value is held in a variable.
                             * testQuery.CommandTimeout = 300;
                             */

                            testQuery.CommandTimeout = m_QueryTimeout;
                            testQuery.Transaction = Transaction;                           

                            using (SqlDataAdapter adapter3 = new SqlDataAdapter(testQuery))
                            {
                                adapter3.Fill(GlobalData.g_queryData);

                                // Open the DataSetViewer form and send the table to it
                                DataSetViewer dsv = new DataSetViewer();
                                dsv.SetSource(GlobalData.g_queryData);
                                // set the dataview classification 05272015
                                string strClassification = string.Format("{0} {1}", GlobalStr.g_classification, GlobalStr.g_releaseability);
                                dsv.setClassification(strClassification);
                                Cursor.Current = Cursors.Default;
                                dsv.ShowDialog();

                                //dataGridView1.DataSource = GlobalData.g_queryData;
                            }
                        }
                        connection.Close();
                    }
                    catch (Exception ex)
                    {
                        /// Print error message
                        MessageBox.Show("The query test failed: " + ex.Message);
                        return;
                    }
                }

AnswerRe: Need to cancel BackgroundWorker Pin
Pete O'Hanlon1-Sep-16 21:01
mvePete O'Hanlon1-Sep-16 21:01 
GeneralRe: Need to cancel BackgroundWorker Pin
David_416-Sep-16 8:12
David_416-Sep-16 8:12 
GeneralRe: Need to cancel BackgroundWorker Pin
Pete O'Hanlon6-Sep-16 9:39
mvePete O'Hanlon6-Sep-16 9:39 
AnswerRe: Need to cancel BackgroundWorker Pin
Gerry Schmitz3-Sep-16 6:53
mveGerry Schmitz3-Sep-16 6:53 
GeneralRe: Need to cancel BackgroundWorker Pin
David_416-Sep-16 8:20
David_416-Sep-16 8:20 
GeneralRe: Need to cancel BackgroundWorker Pin
Gerry Schmitz6-Sep-16 9:08
mveGerry Schmitz6-Sep-16 9:08 
GeneralRe: Need to cancel BackgroundWorker Pin
David_416-Sep-16 9:14
David_416-Sep-16 9:14 
GeneralRe: Need to cancel BackgroundWorker Pin
David_416-Sep-16 9:18
David_416-Sep-16 9:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.