All i am trying to do is make a mySQL local data base that keeps track of first name, last name, and birthday. The main part i need help with is how to access this Data base in the code.
Can some one point me to a simple/basic tutorial of using a mySql local DB in a C# program.?
I would learn mySQL first.
Learn how to create a database, and grant privileges to a user. You do not have to create a database or grant privileges from your C application (although you can). You can run them in mySQL from the command editor included in the download. The link below is a tutorial that demonstrates how to do so in JJAVA, but the SQL is platform independent, so you can user the SQL statements in the article in C language. May sound confusing but, trust me.
http://www.developer.com/java/data/artic...
Afterwards, you want to query the language to create and manipulate tables in the database.
Once you learn the language you just put your query statements inside the C function that is responsible for creating a query transaction to the mySQL Server.
an example in Java,
//define login info
//String username = password = "yourinfo";
//define SQL query (you could use this declaration in C too!)
String query = "CREATE TABLE TestDataBase";
//create connection to mySQL server
Connection c = DriverManager.connect("mysql:localhost:3... username, password);
//a statement object creates a query transaction
Statment s = c.createStatement();
//query the database and save the results
ResultSet rs = s.executeQuery(query);
//address the first record and get the value under a column
rs.first();
String birthDay = rs.getObject("birthday");
System.out.println(birthDay);
columbine
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment