Jump to content


  • Posts

  • Joined

  • Last visited

Newbie89's Achievements


Newbie (1/7)



  1. Ya,I don't want the program to sleep for that minute.I want it perform repeatably like insert,delete,insert,delete...
  2. Can some help me check and recorrect my code? I try and found that something wrong in my code.In my code just for one minute to keep data.How do I keep data for each 1 minute?
  3. How to store data for 1 minute then update the database?any idea to do it?using sqlite and c language...is it just use delete and insert query to make it?
  4. hi...finally I can create the database...but I still can't find the problem which the semicolon no response...the output that I show on top...
  5. Below is my output: hong@ubuntu:~/Check$ sqlite3 hong.sl3<create.sqlhong@ubuntu:~/Check$ gcc -o insert insert.c -lsqlite3hong@ubuntu:~/Check$ ./insertEnter the number of data to be inserted1Enter the name of the student for insertJohnEnter the date, month, year of the student12 12 2012Enter the time12.00Enter the matrix number of the student for insert091232432=======================================1|10/10/2012|9.35am|Kean Heng|91021434=======================================We received 1 records.Total rows=100hong@ubuntu:~/Check$
  6. My problem now is I can get the create.sql from c language,but I can't insert the data in the database.
  7. Can help me see the problem?Below is my code Create.sql create table student (No integer primary key autoincrement, Date1 varchar(20), Time varchar(10),Name varchar(10), Id_no integer); insert into student (Date1 , Time, Name, Id_no) values ('10/10/2012', '9.35am', 'Kean Heng', '091021434'); insert.c # include <stdio.h> # include <sqlite3.h> # include <stdlib.h> int main(void) { sqlite3 *conn; sqlite3_stmt *res; int error = 0; int rec_count = 0; const char *errMSG; const char *tail; char sql_lite[900]=" "; char name[50]; int date=0,month=0,year=0,matrix_number=0,number,x; float time =0; error = sqlite3_open("hong.sl3", &conn); if (error) { printf("Can not open database"); } printf("Enter the number of data to be inserted\n"); scanf("%d",&x); for(number=x;number>0;number--) { printf("Enter the name of the student for insert\n"); scanf("%s",name); printf("Enter the date, month, year of the student\n"); scanf("%d%d%d",&date,&month,&year); printf("Enter the time \n"); scanf("%f",&time); printf("Enter the matrix number of the student for insert\n"); scanf("%d",&matrix_number); } sprintf(sql_lite, "insert into student values ('%d/%d/%d','%.2fam','%s',%d);",date,month,year,time,name,matrix_number); error = sqlite3_exec(conn, sql_lite, 0, 0, 0); error = sqlite3_prepare_v2(conn, "select * from student order by No",1000, &res, &tail); if (error != SQLITE_OK) { printf("We did not get any data!"); exit(0); } printf("=======================================\n"); while (sqlite3_step(res) == SQLITE_ROW) { printf("%d|", sqlite3_column_int(res, 0)); printf("%s|", sqlite3_column_text(res, 1)); printf("%s|", sqlite3_column_text(res, 2)); printf("%s|", sqlite3_column_text(res, 3)); printf("%u\n", sqlite3_column_int(res, 4)); rec_count++; } printf("=======================================\n"); printf("We received %d records.\nTotal rows=%d\n", rec_count,SQLITE_ROW); sqlite3_finalize(res); sqlite3_close(conn); return 0; }
  8. How to insert data in the last row but not in the first row using C language.Do sqlite have function that control the row of the insert?I want the sequential row numbers from insert query.Thanks.
  9. #include <stdio.h>#include <sqlite3.h>#include <stdlib.h>static char *createsql = "CREATE TABLE Employee(" "ID INTEGER PRIMARY KEY," "Name VARCHAR(10)," "BadgeID VARCHAR(10));";static char *insertsql = "INSERT INTO Employee VALUES(NULL, 'Danny', '12345');";static char *querysql = "SELECT * FROM Employee;";void main(void){int i,j;int rows, cols;sqlite3 *db;char *errMsg = NULL;char **result;/* Open database file */if (sqlite3_open("my_example.db3", &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL)){ return ;}/* Build Table */ sqlite3_exec(db, createsql, 0, 0, &errMsg);/* Add a new record */ sqlite3_exec(db, insertsql, 0, 0, &errMsg);/* Get the last insert record's ID */ printf("%d\n", sqlite3_last_insert_rowid(db));/* Get all records in database */ sqlite3_get_table(db , querysql, &result , &rows, &cols, &errMsg);/* List all the data */ for (i=0;i<rows;i++){ for (j=0;j<cols;j++) { printf("%s\t", result[i*cols+j]); } printf("\n");} /* Free table */ sqlite3_free_table(result);/* Close database */ sqlite3_close(db);} Above is the code...When I'm compile it,I get the error in the terminal: hong@ubuntu:~/test$ gcc -lsqlite3 -o sqlite_exp sqlite_exp.csqlite_exp.c: In function ‘main’:sqlite_exp.c:18:1: error: too many arguments to function ‘sqlite3_open’/usr/include/sqlite3.h:2579:16: note: declared heresqlite_exp.c:32:1: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘sqlite3_int64’ [-Wformat] Can anyone help me point out the correction?thanks...
  10. I have succesfully compile the sqlite-amalgamation-3071300 and extract the file.After that I compile the sqlite3.c into the SBC TS-5500.When execute the sqlite command,it show no response with the next line,anyone can help me solve this problem?Below is my output problem:[root@miniepc Hong]#./a.out SQLite version 3.7.13 2012-06-11 02:05:22 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> create table artist(ID INTEGER PRIMARY KEY,Artist_name TEXT); ...> insert into artist(NULL,'hong'); ...> select * from artist; ...> .quit ...>
  11. I have try to create the database through pdo and use gd library to create simple graph seperately.Below is my php script which is FYP.php and gd_sql.php.The problem now is to combine both of them.(Get data from sqlite database and display as simple XY graph) FYP.php gd_sql.php
  12. How to call sqlite database and generate XY graph such as statistic.Any website that related with this question?Or can give me step to do it?Thanks
  • Create New...