Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a Books database to include two tables: BookTable and Course- BookTable.

ID: 3686365 • Letter: C

Question

Create a Books database to include two tables: BookTable and Course- BookTable. The BookTable table should have fields for ISBN number, title, copyright date, primary author, publisher, and number of pages. The CourseBookTable table should have fields for course number and ISBN. Populate the tables with books in your current collection, including the books you are using for your classes. Books that are not associated with a specific course can be placed in the table with a FUN course number. The type of database (SQL Server or Access) will be determined by your instructor. Write a C# program to display the course number (or FUN) and the ISBN and name of the book on the same screen. Use MS-Access DBMS to create your database.

Explanation / Answer

public Book readFromDataBase(string fName)
{
var con = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();

Book book = new Book();
using (SqlConnection myConnection = new SqlConnection(con))
{
string oString = "Select courseNumber,ISBN,Name from CourseBook AS C,Book AS B where C.ISBN=B.ISBN";
SqlCommand oCmd = new SqlCommand(oString, myConnection);
myConnection.Open();
using (SqlDataReader oReader = oCmd.ExecuteReader())
{
while (oReader.Read())
{
book.courseNumber = oReader["courseNumber"].ToString();
book.ISBN = oReader["ISBN"].ToString();
book.Name = oReader["Name"].ToString();
}

myConnection.Close();
}   
}
return book;
}