Do not concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead.
Then...change your table names: "tableA" and "tableB" are not descriptive of what the tables contain, which makes it a lot harder to work out what is happening.
Consider having three tables:
Books
Id can be INT, IDENTITY
ISBN
Title
Author
Users
ID can be INT, IDENTITY
Name
Address
Loans
ID can be INT, IDENTITY
BookID
UserID
LoanDate DATETIME
DueDate DATETIME
ReturnDate DATETIME NULLABLE
Each book has a unique ID, but "identical books" share an ISBN - so you track the individual book rather than a generic "one of these" type stack.
From this, you can work out everything you need using simple JOIN statements - and you don't need to delete records: you just update them so you can "trace the history" of a book as well. So if I borrow a book and find the middle section has been torn out, you can look back in the records to find out who to blame!
Have a think about it - it's a lot easier to use than you might think, and while it means throwing away your existing code and starting again I have to say that looking at your code that wouldn't be a bad idea...
Set up a single static connection string - that way if it changes (and it does) you don't have to change it in many places (the best way is to use a configuration file so you app doesn't have to be changed when the connections string does).
Close and Dispose of your Connections, Commands, Readers and so forth. use a
using
block is the simplest way.
Don't use ExecuteReader for UPDATE commands - they don't return anything. USe ExecuteNonQuery instead.
Be consistent in your naming conventions:
modData
and
modCommandData
are ok (though most people tend to use
com
and
cmd
respectively) but then you go with
MyReader
which doesn't fit.
Why are you Hiding a form? This is an unusual thing to do...particularly for a library based system...
I know this is your homework, and that you are a beginner - and that is sounds like I am being harsh on you - but this doesn't look like you sat down and thought about what you have to do - it looks like you leapt in and started coding from the beginning instead! :laugh: If you do stop and think, you will get a system that is easier to use and easier to code - honest!