As this is clearly a homework I will not give you complete code. I will give you a couple of hints instead which should help you to do it yourself.
It is a good practice to filter data as soon as possible. In this case you should filter records by customer at the database level. This limits the amount of data that needs to be transferred from database to your application and for you there is then less work in processing those records too. That applies to both rows and columns. If you are asked to provide shipped date then this is exactly what you should be selecting.
SELECT *
is considered a
bad practice[
^] for several reasons. So your select should look like this:
SELECT ShippedDate FROM ShippingTable WHERE CustomerId = @customerId
In this query
@customerId
is a parameter. You need to learn how to add
parameters[
^] to your database command. You are loading the resulting data into a
DataTable
so you may want to explore
data adapters[
^] to make your job easier.
Final step is printing the loaded data. Well, you already have that code. What you need to do is extract it to a method so you can reuse it.