close
  • 홈
  • :
  • 위치로그
  • :
  • 태그
  • :
  • 방명록
  • :
  • 관리자
  • :
  • 새글쓰기
블로그 이미지

이슬나라 [isulnara.com]
프로그램 관련 문의...
전체 (208)
자작 프로그램 (24)
EzIP (3)
IEPageSetup (3)
iSysInfoX (2)
메신저 알림이 (1)
ezSVC (1)
WebFTP (2)
iDebugX (1)
기타 (10)
버그 신고 (1)
이것저것.. (55)
WebFTP 게시판 (0)
팁 모음 (77)
linux (21)
프로그래밍 (36)
윈도우 (5)
네크워크 (7)
기타 (7)
윈도우 숨은.. (4)
터미널 서비스.. (1)
공개 웹하드 (1)
관리자 (0)
PC 원격제어.. (1)
NAS (43)
«   2012/02   »
일 월 화 수 목 금 토
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29      
php DS209+II AjaXplorer 나스 태터툴즈 아이피 병돌리기 SQL Server jndi 지그비 ftpls ftplist ftpdir location.replace CRC ezlink 날짜비교 블록 IE apache zotac SQLSERVER MACAddress usb station2 sms Andorid Spin The Bottle 델파이 WebFTP backup 다운로드스테이션 Points
[ezLink] 동시 접속수...
ezLink 1.2.1.2 정식... (3)
MD5 CRC 체크섬.
Apache, Subversion...
CentOS에 MongoDB 설치.
예.. 제가 직접 만들어서...
isul / 01/29
직접 만드시는 프로그램...
LuckySh / 01/28
109j용 1869가 synology...
isul / 01/22
Ds-109j 1869 가지고 계...
심재규 / 01/21
시도해보지는 않았지만 S...
isul / 01/20
일반 어플리케이션을 서...
ㅇㅇ/ / 2009
사이코웨어 : nProtect,...
√ MIRiyA's AstraLog / 2008
웹페이지에서 인쇄시 머...
醉生夢死™ / 2006
웹페이지에서 MAC Addres...
날자~!! 날어~!! / 2005
 최근글 목록
 2011/11 [2]
 2011/10 [3]
 2011/09 [1]
 2011/07 [3]
 2011/06 [1]
넷하드 - NAS 카페
무료 원격제어 프로그램
블로그가 뭥미?
솔라리스 테크넷
스티브 맥코넬
시놀로지 NAS 카페
하얀나무 - 캠핑 전문 쇼핑몰
하얀나무's Story
Total of
456360 visitors
Today 67
Yesterday 189
 
글검색결과[pascal] : 1
2009/05/06  Free pascal에서 SQLite 사용하기
     
 팁 모음/프로그래밍 
Free pascal에서 SQLite 사용하기
Posted on 2009/05/06 00:23
 
 
 
 
Free Pascal이나 Lazarus에 기본으로 있는 sqlite 관련 컴포넌트를 리눅스 환경에서 사용할 경우 Close나 Free를 호출할 경우 알 수 없는 에러가 발생하더군요.
그래서 sqlite 라이브러리를 직접 호출하는 방법을 사용했습니다.
아래는 소스 코드입니다.

uses sqlite3;

procedure TAlertD.InsertMessageToDB(email, contents, ip: string);
var
  rc: longint;
  db: Psqlite3;
  query: string;
  stmt: Psqlite3_stmt;
  idx0, idx1, idx2, idx3: Integer;
begin
  rc := sqlite3_open(PChar(ExpandFileName(ChangeFileExt(ParamStr(0), '.db3'))), @db);
  if (rc <> SQLITE_OK) then
    begin
      WriteLn('Can''t open database');
      sqlite3_close(db);
      Exit;
    end;

  rc := sqlite3_exec(db, 'BEGIN', nil, nil, nil);
  if rc <> SQLITE_OK then
    begin
      WriteLn('Can''t begin Transaction: ', sqlite3_errmsg(db));
      sqlite3_close(db);
      Exit;
    end;

  query := ' INSERT INTO message(email, contents, sender_ip, reg_date) VALUES(:email, :contents, :ip, :reg_date) ';
  rc := sqlite3_prepare(db, PChar(query), Length(query), @stmt, nil);
  if rc = SQLITE_OK then
    begin
      idx0 := sqlite3_bind_parameter_index(stmt, ':email');
      idx1 := sqlite3_bind_parameter_index(stmt, ':contents');
      idx2 := sqlite3_bind_parameter_index(stmt, ':ip');
      idx3 := sqlite3_bind_parameter_index(stmt, ':reg_date');

      sqlite3_bind_text(stmt, idx0, PChar(email), Length(email), SQLITE_STATIC);
      sqlite3_bind_text(stmt, idx1, PChar(contents), Length(contents), SQLITE_STATIC);
      sqlite3_bind_text(stmt, idx2, PChar(ip), Length(ip), SQLITE_STATIC);
      sqlite3_bind_text(stmt, idx3, PChar(FormatDateTime('yyyy-mm-dd hh:nn:ss', now)), Length(FormatDateTime('yyyy-mm-dd hh:nn:ss', now)), SQLITE_STATIC);

      rc := sqlite3_step(stmt);
      if rc <> SQLITE_DONE then
        begin
          WriteLn('sqlite3_step error: ', sqlite3_errmsg(db));
          sqlite3_close(db);
          Exit;
        end;

      rc := sqlite3_exec(db, 'COMMIT', nil, nil, nil);
      if rc <> SQLITE_OK then
        begin
          WriteLn('Commit error: ', sqlite3_errmsg(db));
          sqlite3_close(db);
          Exit;
        end;
    end
  else
    begin
      WriteLn('SQL error: ', sqlite3_errmsg(db));
    end;

  sqlite3_finalize(stmt);
  sqlite3_close(db);
end;

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
이올린에 북마크하기(0) 이올린에 추천하기(0)
pascal, sqlite
Trackback [0] : Comment [0]
TrackbackAddress
http://isulnara.com/tt/trackback/197
SecretComment
  1