title: The format of the URI could not be determined
body: <p>I'm working on application that take attendance records from attendance system and put it inside access file and upload to my web site.
  it's working successfully but but when i focus on other screen in my desktop and go back to the application give this error ! 
  "Invalid URI: The format of the URI could not be determined"</p>
  
  <p>This is the code:</p>
  
  <pre><code>public void BatchTransfert(zkemkeeper.CZKEMClass axCZKEM1, int index, BackgroundWorker worker, DoWorkEventArgs e)
      {
          string sdwEnrollNumber ="";
          int idwEnrollNumber = 0;
          int idwTMachineNumber = 0;
          int idwEMachineNumber = 0;
          int idwVerifyMode = 0;
          int idwInOutMode = 0;
          int idwYear = 0;
          int idwMonth = 0;
          int idwDay = 0;
          int idwHour = 0;
          int idwMinute = 0;
          int idwSecond = 0;
          int idwWorkcode = 0;
  
          int idwWorkCode = 0;
          int idwReserved = 0;
  
          int idwErrorCode = 0;
          int iGLCount = 0;
          int iIndex = 0;
  
          string time;
          string pcTime = DateTime.Now.Year.ToString() + "-" + GetMonthName(DateTime.Now.Month).ToString() + "-" + DateTime.Now.Day.ToString() + " " + DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString() + ":" + DateTime.Now.Second.ToString();
          string userID;
          int AttStat;
  
          DataSet ds = new DataSet();
          DataTable AttendanceLogs = new DataTable();
          DataColumn USERID = new DataColumn();
          USERID.DataType = System.Type.GetType("System.String");
          USERID.ColumnName = "USERID";
  
          DataColumn CHECKTIME = new DataColumn();
          CHECKTIME.DataType = System.Type.GetType("System.String");
          CHECKTIME.ColumnName = "CHECKTIME";
  
          DataColumn CHECKTYPE = new DataColumn();
          CHECKTYPE.DataType = System.Type.GetType("System.Int32");
          CHECKTYPE.ColumnName = "CHECKTYPE";
          AttendanceLogs.Columns.Add(USERID);
          AttendanceLogs.Columns.Add(CHECKTIME);
          AttendanceLogs.Columns.Add(CHECKTYPE);
  
          ds.Tables.Add(AttendanceLogs);
          string sqlOnlineUpdate = "";
          string deviceIPAdress = "";
          try
          {
  
              Cursor = Cursors.WaitCursor;
              axCZKEM1.EnableDevice(iMachineNumber[index], false);//disable the device
              if (axCZKEM1.ReadGeneralLogData(iMachineNumber[index]))//read all the attendance records to the memory
              {
  
                  while (axCZKEM1.IsTFTMachine(iMachineNumber[index]) ?
                          axCZKEM1.SSR_GetGeneralLogData(iMachineNumber[index], out sdwEnrollNumber, out idwVerifyMode, out idwInOutMode, out idwYear, out idwMonth,
                          out idwDay, out idwHour, out idwMinute, out idwSecond, ref idwWorkCode) //TFt machine
                          :
                          axCZKEM1.GetGeneralLogData(iMachineNumber[index], ref idwTMachineNumber, ref idwEnrollNumber, ref idwEMachineNumber, ref idwVerifyMode,
                          ref idwInOutMode, ref idwYear, ref idwMonth, ref idwDay, ref idwHour, ref idwMinute)) //ref idwSecond ref idwWorkCode))
                  {
                      iGLCount++;
                      time = idwYear.ToString() + "-" + GetMonthName(idwMonth).ToString() + "-" + idwDay.ToString() + " " + idwHour.ToString() + ":" + idwMinute.ToString() + ":" + idwSecond.ToString();
                      pcTime = DateTime.Now.Year.ToString() + "-" + GetMonthName(DateTime.Now.Month).ToString() + "-" + DateTime.Now.Day.ToString() + " " + DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString() + ":" + DateTime.Now.Second.ToString();
                      userID = axCZKEM1.IsTFTMachine(iMachineNumber[index]) ? sdwEnrollNumber : idwEnrollNumber.ToString();
                      AttStat = idwInOutMode;
                      DataRow newRow = AttendanceLogs.NewRow();
                      newRow["USERID"] = userID;
                      newRow["CHECKTIME"] = time;
                      newRow["CHECKTYPE"] = idwInOutMode;
                      AttendanceLogs.Rows.Add(newRow);
                  }
  
  
                  string filename = Application.StartupPath + "\\config.txt";
                  Serializer serializeFromFile = new Serializer();
                  settings = serializeFromFile.DeSerializeObject(filename);
  
                  //axCZKEM1.Disconnect();
                  axCZKEM1.EnableDevice(iMachineNumber[index], true);//enable the device
                  if (AttendanceLogs.Rows.Count &gt; 0)
                  {
                      int i = 0;
                      progressBar1.Enabled = true;
                      progressBar1.Maximum = AttendanceLogs.Rows.Count;
                      progressBar1.Visible = true;
                      labelProgress.Visible = true;
  
                      String connString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + settings.localDBPath;
                      OleDbConnection conn = new OleDbConnection(connString);
                      conn.Open();
                      axCZKEM1.GetDeviceIP(iMachineNumber[index], ref deviceIPAdress);
  
  
                      string sqlSelect;
                      string queryString;
                      string onlineApp;
                      string urlAdress;
  
  
                      #region UploadData
                      foreach (DataRow row in AttendanceLogs.Rows)
                      {
                          try
                          {
                              if (worker.CancellationPending == true)
                              {
                                  e.Cancel = true;
                                  break;
                              }
                              else
                              {
                                  i++;
                                  progressBar1.Value = i;
                                  //Connection Info for Local DB                            
                                  sqlSelect = "Select * from CHECKINOUT WHERE USERID = " + row["USERID"] + " and CHECKTIME = #" + row["CHECKTIME"] + "#  and CHECKTYPE = '" + row["CHECKTYPE"] + "'";
                                  OleDbCommand cmd = new OleDbCommand(sqlSelect, conn);
                                  OleDbDataReader dataReader = cmd.ExecuteReader();
                                  //Saving in local Db
                                  if (!dataReader.HasRows)
                                  {
  
                                      queryString = "userID=" + row["USERID"] + "&amp;time=" + row["CHECKTIME"] + "&amp;AttStat=" + row["CHECKTYPE"] + "&amp;pcTime=" + pcTime + "&amp;schoolID=" + schoolID + "&amp;schoolName=" + schoolName + "&amp;machineName=" + machineName;
  
                                      onlineApp = settings.onlinURL + @"/Admin/HR/Attendance_UpdateData.ashx?" + queryString;
                                      urlAdress = onlineApp;
                                      Uri url = new Uri(urlAdress);
                                      HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(url);
                                      webReq.Method = "Get";
  
                                      HttpWebResponse myWebResponse = (HttpWebResponse)webReq.GetResponse();
                                      if (myWebResponse.ContentLength == 7)
                                      {
                                          dataReader.Close();
                                          string sqlUpdate = "INSERT INTO CHECKINOUT ( USERID, CHECKTIME, CHECKTYPE )"
                                                              + "VALUES (" + row["USERID"] + ", #" + row["CHECKTIME"] + "#, " + row["CHECKTYPE"] + ")";
                                          cmd.CommandText = sqlUpdate;
                                          dataReader = cmd.ExecuteReader();
                                      }
                                      myWebResponse.Close();
                                  }
                                  labelProgress.Text = "Transfering data from device IP : " + deviceIPAdress + ".... " + progressBar1.Value.ToString() + " / " + progressBar1.Maximum.ToString();   //row["USERID"];
                                  labelProgress.Refresh();
                                  dataReader.Close();
                                  dataReader.Dispose();
                              }
                          }
  
                          catch (SqlException sqlExp)
                          {
                              MessageBox.Show(sqlExp.Message);
                              EventLog.WriteEntry("User ID", sqlExp.Message, EventLogEntryType.Information, 15);
                              SendMail("School : " + machineName + " / 'Method Batch Down' Error in Online database Conn : " + sqlExp.Message + "\n" + "Sql Query : " + sqlOnlineUpdate);
                          }
  
                          catch (Exception exp)
                          {
                              MessageBox.Show("Herre Apear the Error!!!!!!!!" + exp.Message + "  +" + exp.HelpLink);
                              EventLog.WriteEntry("RFID finger Print", exp.Message, EventLogEntryType.Information, 15);
                              SendMail("School : " + machineName + " / 'Method Batch Down' Error in Transfert Data : " + exp.Message + "\n" + "Sql Query : " + sqlOnlineUpdate);
                          }
                      }
                      #endregion
                      //conn.Close();
                      //conn.Dispose();
                  }
  
                  //objConn.Close();
              }
              else
              {
                  Cursor = Cursors.Default;
                  axCZKEM1.GetLastError(ref idwErrorCode);
  
                  if (idwErrorCode != 0 &amp;&amp; idwErrorCode != -2)
                  {
                      //MessageBox.Show("Reading data from terminal failed,ErrorCode: " + idwErrorCode.ToString(), "Error");
                      SendMail("Reading data from terminal failed, ErrorCode: " + idwErrorCode.ToString());
                  }
                  else
                  {
                      //SendMail("No data from terminal returns!, ErrorCode: " + idwErrorCode.ToString());
                  }
              }
              axCZKEM1.EnableDevice(iMachineNumber[index], true);
              labelProgress.Visible = false;
              progressBar1.Visible = false;
              Cursor = Cursors.Default;
          }
  
          catch (SqlException sqlEx)
          {
  
              EventLog.WriteEntry("User ID", sqlEx.Message, EventLogEntryType.Information, 15);
              SendMail("School : " + machineName + " / 'Method Batch Down' Error in Online database Conn : " + sqlEx.Message + "\n" + "Sql Query : " + sqlOnlineUpdate);
          }
  
          catch (Exception ex)
          {
              EventLog.WriteEntry("RFID finger Print", ex.Message, EventLogEntryType.Information, 15);
              //SendMail("School : " + machineName + " / 'Method Batch Down' Error in Transfert Data : " + ex.Message + "\n" + "Sql Query : " + sqlOnlineUpdate);
          }
      }
  </code></pre>