附录一 Mytest.c
/****************************************************************/
/* Author: Allen Lee TS : 2/ 4/2004 9:15 */
/* Date: 2/ 4/2004 */
/* mytest.c : test DDL statment*/
/* */
/* History: */
/* */
/****************************************************************/
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <mysql.h>
#define STRING_SIZE 50
#define DROP_SAMPLE_TABLE "DROP TABLE IF EXISTS test_table"
#define CREATE_SAMPLE_TABLE "CREATE TABLE test_table(col1 INT,\
col2 VARCHAR(40),\
col3 SMALLINT,\
col4 TIMESTAMP)"
#define INSERT_SAMPLE "INSERT INTO test_table(col1,col2,col3) VALUES(?,?,?)"
int main(int argc, char **argv){
MYSQL *mysql;
mysql = mysql_init(NULL);
if(!mysql_real_connect(mysql, "localhost","root","","",3306,"",NULL)){ /* Make connection with mysql_connect(MYSQL db, char *host, char *username, char *password */
printf(mysql_error(mysql));
exit(1);
}
if(mysql_select_db(mysql, "test")){ /* Select the database we want to use */
printf(mysql_error(mysql));
exit(1);
}
MYSQL_STMT *stmt;
MYSQL_BIND bind[3];
my_ulonglong affected_rows;
int param_count;
short small_data;
int int_data;
char str_data[STRING_SIZE];
unsigned long str_length;
my_bool is_null;
if (mysql_query(mysql, DROP_SAMPLE_TABLE))
{
fprintf(stderr, " DROP TABLE failed\n");
fprintf(stderr, " %s\n", mysql_error(mysql));
exit(0);
&nbs [1] [2] [3] [4] [5] 下一页 没有相关教程
|