joe_pool_is
Well-known member
In my code, I have a couple of different methods of calling my database. Im not a database guy, so I dont know the names of the methods I am using.
One method takes a DataAdapter (Adapter1) with an SQL string command (strSql) and a Database Connection (Connection1), then magically does its thing by calling Adapter1.Fill(DatabaseTable1). I dont understand how it works, but I use it in a few places, and it seems to work. Pure magic!
The other method makes sense to me: Construct a similar SQL string command (strSql) and Database Connection (Connection1), but then supply these settings to a DbCommand (Command1). For this version, I have to use Connection1.Open() along with Command1.ExecuteNonQurey(), then include a "finally" statement with Connection1.Close().
The first method seems more elegant, but I dont know how to make it work for all situations that I might have, particularly when doing INSERT or UPDATE commands, as these to not return anything that Adapter1 would be expecting.
My degree is in physics, but I like writing programs more. I have taken several programming courses and several database courses, but the programming courses, at best, include a chapter on how to work with databases. Meanwhile, books on databases seem to think that everyone is going to work with the database using their front end.
Right now, I would like to learn how to create queries for my databases, but the books I have only show how to create a query using their front ends. Take a query such as:
"UPDATE table7 SET value2=" + txtValue2.Text + " WHERE value9=" + txtValue9.Text + ";"
How do I enter the txtValue2 and txtValue9 fields into this query if they are not included in the databases front end? Also, this is called a "stored procedure", right? Provided my Access database allows me to use the names txtValue2 and txtValue9, how do I make my program flexible by using this query with other values, such as txtValue112.Text and String1? (You get the point, right?)
Where is a good spot for a physics guy to learn this type of stuff? I have a bookshelf full of different books on different techniques, but they are either too darned basic (This is called a keyboard, and this is called a floppy drive) or they get waaaaay too involved for me to follow (this writes to the kernel, and requires covering all 15 different possibilities while modifying the Northwind database). Id just like a good spill on how to do some basic database stuff in the first chapter or two, spend the meat of the book showing me how to do moderate things like queries and stored procedures, then maybe get into covering relational databases with queries spanning two or three tables later in the book. It doesnt even need to be 400 pages! Really, 20 pages are just fine if I get the point. As for databases, Microsoft Access is preferred, because I havent ever been able to get that darned SqlServer installed fully on my computer. Im sure its great, but I cant seem to get it to work for me. Microsoft Access is easy, and for the little stuff I do, it is working great for the moment. Maybe one day I can graduate to SqlServer, but not today.
This may look long enough to be a blog, but it just represents a lot of the frustration Ive come across while trying to get database programming to work. I get such a rush when it finally works, but getting the darned thing to work is worse than pulling teeth!
My preferred language is C#, but I can generally figure out what VB means if I look at it for a while and maybe turn my head sideways a bit.
One method takes a DataAdapter (Adapter1) with an SQL string command (strSql) and a Database Connection (Connection1), then magically does its thing by calling Adapter1.Fill(DatabaseTable1). I dont understand how it works, but I use it in a few places, and it seems to work. Pure magic!
The other method makes sense to me: Construct a similar SQL string command (strSql) and Database Connection (Connection1), but then supply these settings to a DbCommand (Command1). For this version, I have to use Connection1.Open() along with Command1.ExecuteNonQurey(), then include a "finally" statement with Connection1.Close().
The first method seems more elegant, but I dont know how to make it work for all situations that I might have, particularly when doing INSERT or UPDATE commands, as these to not return anything that Adapter1 would be expecting.
My degree is in physics, but I like writing programs more. I have taken several programming courses and several database courses, but the programming courses, at best, include a chapter on how to work with databases. Meanwhile, books on databases seem to think that everyone is going to work with the database using their front end.
Right now, I would like to learn how to create queries for my databases, but the books I have only show how to create a query using their front ends. Take a query such as:
"UPDATE table7 SET value2=" + txtValue2.Text + " WHERE value9=" + txtValue9.Text + ";"
How do I enter the txtValue2 and txtValue9 fields into this query if they are not included in the databases front end? Also, this is called a "stored procedure", right? Provided my Access database allows me to use the names txtValue2 and txtValue9, how do I make my program flexible by using this query with other values, such as txtValue112.Text and String1? (You get the point, right?)
Where is a good spot for a physics guy to learn this type of stuff? I have a bookshelf full of different books on different techniques, but they are either too darned basic (This is called a keyboard, and this is called a floppy drive) or they get waaaaay too involved for me to follow (this writes to the kernel, and requires covering all 15 different possibilities while modifying the Northwind database). Id just like a good spill on how to do some basic database stuff in the first chapter or two, spend the meat of the book showing me how to do moderate things like queries and stored procedures, then maybe get into covering relational databases with queries spanning two or three tables later in the book. It doesnt even need to be 400 pages! Really, 20 pages are just fine if I get the point. As for databases, Microsoft Access is preferred, because I havent ever been able to get that darned SqlServer installed fully on my computer. Im sure its great, but I cant seem to get it to work for me. Microsoft Access is easy, and for the little stuff I do, it is working great for the moment. Maybe one day I can graduate to SqlServer, but not today.
This may look long enough to be a blog, but it just represents a lot of the frustration Ive come across while trying to get database programming to work. I get such a rush when it finally works, but getting the darned thing to work is worse than pulling teeth!
My preferred language is C#, but I can generally figure out what VB means if I look at it for a while and maybe turn my head sideways a bit.