title: Packaging System.Data.SqlClient with a class library in C#
body: <p>I have a scanner add-in that I'm working on that uses C#.</p>
  
  <p>My code works on the emulator, but not on the scanner hardware itself.  Could it be because the scanner doesn't have System.Data.SqlClient on it?  I'm not sure.  Is there a way I can specify that System.Data.SqlClient be included in my generated dll file?</p>
  
  <p>The error I get is Named Pipes Provider error 40 on con.Open().  If it were a problem with the scanner not having the library though, woudln't it throw on error at the first reference to a SqlConnection?  The source code is as follows:</p>
  
  <pre><code>String clientName = "";
  
          try
          {
              // Setting up the SqlConnectionStringBuilder
              SqlConnectionStringBuilder buildIt = new SqlConnectionStringBuilder();
              buildIt.DataSource = "xxx.xx.x.xx";
              buildIt.InitialCatalog = "database";
              buildIt.IntegratedSecurity = true;
  
              using (SqlConnection con = new SqlConnection(buildIt.ConnectionString))
              {
                  con.Open();
                  using (SqlCommand command = new SqlCommand("SELECT First_Name, Last_Name FROM background WHERE Patient_No=@Patient_No", con))
                  {
                      command.Parameters.AddWithValue("@Patient_No", clientID);
                      SqlDataReader reader = command.ExecuteReader();
                      if (reader.HasRows)
                      {
                          reader.Read();
                          clientName = reader.GetString(0).Trim() + " " + reader.GetString(1).Trim();
                      } // end if (reader.hasRows)
                      else
                      {
                          // No client found for this ID.
                          return false;
                      } // end else
                  } // end using (SqlCommand command = new SqlCommand("SELECT First_Name, Last_Name FROM background WHERE Patient_No=@Patient_No", con))
              }
          } // end try
          catch (Exception err)
          {
              // Test code.
              // MessageBox.Show(err.Message);
              exporterHost.WriteSystemLog(LogType.Error, "E9999999", "SQL ERROR: " + err.Message);
              return false;
          }
  </code></pre>
  
  <p>Thanks!</p>