I need to get the amount of copies from my local database and use that value to make copies of the pdf file.
public Boolean getAmountOfCopies()
{
string connectionString = null;
MySqlConnection cnn;
connectionString = "databaseInformation";
cnn = new MySqlConnection(connectionString);
try
{
cnn.Open();
Console.WriteLine("Connection Open");
const string sql = "SELECT numberofcopies FROM orders";
MySqlCommand cmd = new MySqlCommand(sql, cnn);
MySqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
if (rdr[0] == null)
{
Console.WriteLine("There is no value, it is null.");
return false;
}
else
{
Console.WriteLine(rdr[0]);
var ImageFiles = Directory.EnumerateFiles(Directory.GetCurrentDirectory()).Where(f => f.EndsWith(".jpg") || f.EndsWith(".JPG") || f.EndsWith(".jpeg") || f.EndsWith(".jfif"));
List<string> images = ImageFiles.ToList();
PdfDocument[] copyOfPDF = new PdfDocument[images.Count()];
// Code goes here to make the copy
}
}
cnn.Close();
Console.WriteLine("Connection Closed");
return true;
}
catch (Exception ex)
{
Console.WriteLine(ex);
return false;
}
}
The rdr[0] is the value being taken from the database in numberofcopies column. I need to use that value to make the amount of copies based on that value.
Hopefully it is not too confusing, if you need clarification please let me know and i will provide further information.
Thank you.
Made it work by adding this.