Fehmi Noyan ISI wrote > I cannot understand "So I need to create a table Packet right?", but you > do need to create a table first. > > You may need to bother yourself by reading the API reference for the > functions I gave.
ok...can help me check my code?some part I not sure...thanks link.c > # include > <sqlite3.h> > # include > <stdlib.h> > # include > <string.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]=" "; > int read_packet=0; > error = sqlite3_open("link.db", &conn); > if (error) > { > printf("Can not open database"); > > } > > > while(read_packet) > { > ProcessPack() > sprintf(sql_lite, "insert into Packet > (No,Dated,Time,Src_MAC,Dest_MAC,Net_P,Trans_P,Src_IP,Dest_IP,Src_Port,Dest_Port,Cap_Bytes) > values ();",); > error = sqlite3_exec(conn, sql_lite, 0, 0, 0); > } > > error = sqlite3_prepare_v2(conn, "select * from Packet 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("%c|", sqlite3_column_char(res, 3)); > printf("%c|", sqlite3_column_char(res, 4)); > printf("%c|", sqlite3_column_char(res, 5)); > printf("%c|", sqlite3_column_char(res, 6)); > printf("%c|", sqlite3_column_char(res, 7)); > printf("%c|", sqlite3_column_char(res, 8)); > printf("%d|", sqlite3_column_int(res, 9)); > printf("%d|", sqlite3_column_int(res, 10)); > printf("%d\n", sqlite3_column_int(res, 11)); > > > > rec_count++; > } > > > printf("=====================================================\n"); > printf("We received %d records.\n", rec_count); > > sqlite3_finalize(res); > > sqlite3_close(conn); > > return 0; > } > } link.sql <quote create table Packet(No integer promary key,Dated text,Time text,Src_MAC char(18),Dest_MAC char(18),Net_P char(5),Trans_P char(5),Src_IP char(16),Dest_IP char(16),Src_Port long int,Dest_Port long int,Cap_Bytes long int); </quote> -- View this message in context: http://sqlite.1065341.n5.nabble.com/How-to-link-the-packet-in-C-file-then-store-in-sqlite-database-tp68593p68615.html Sent from the SQLite mailing list archive at Nabble.com. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users