Jump to content

Sgl Veri Tabanında Bağlantıyı Sonlandırma


korasoglu
 Share

Recommended Posts

Arkadaşlar nerede hata var anlamadım veri tabanına bağlanıyor yazdırırken hata varsa hatayı söylüyor bağlantıyı kes dedinmi hata veriyor yardımlarınızı bekliyorum.

 

Global
---------------------
sql = {
baglan = function()
SQLite3Connection, err = SQLite3:connect(_SourceFolder .. "\\veri.db", "", "");
end,
 
kapat = function()
db:close();
SQLite3Connection:close()
end
}
 
kaydet
-------------------------
if adi ~= "" and soyadi ~= ""  and tel ~= "" then
sql.baglan();
db, err = SQLite3Connection:execute("INSERT INTO kisiler (adi, soyadi, tel) VALUES ('" .. adi .. "', '" .. soyadi .. "', '" .. tel .. "',)")
if not db and err then
Dialog.Message("Hata", err)
Application.ExitScript();
else
sql.kapat();
DialogEx.Close();
end
else
Dialog.Message("Hata", "gerekli yerleri doldurunuz!", MB_OK, MB_ICONSTOP, MB_DEFBUTTON1) -- hata ver
end
Link to comment
Share on other sites

sSql = "";
if not tSql then tSql= {}; end

tSql.Baglan = function (sSql)
if (sSql == "") then sSql = _SourceFolder.."\\MyDataBase.db"; end
SQLite3Connection, err = SQLite3:connect(sSql, "", "");
end


tSql.Close = function()
SQLite.Finalize(sSql);
end

Farkı bir örnek:

if (Folder.DoesExist(_TempFolder)) then --- eğer temp klasörü pc de mevcut ise
Folder.Create(_SourceFolder.."\\Database"); -- bir klasör oluşturuyoruz
sDB = SQLite.Open(_SourceFolder.."\\Database\\MyDatabase.db"); -- veri tabanı dosyasını oluşturuyoruz
SQLite.Query(sDB, "create table MyTable (id integer primary key, Path1 text,  Path2 text)"); --isteğimize göre bir tablo oluşturuyoruz
end
local Path1 = "My Text";
local Path2 = "My Text";
SQLite.Query(sDB,"insert into MyTable values(NULL,'"..Path1.."', '"..Path2.."')"); -- değerleri tabloya depoluyoruz

Veri tabanı bağlantısını kesmek için:

SQLite.Finalize(sDB);
collectgarbage();
Temp klasörünü kontrol etmemim sebebi bazen temp pc den silinebiliyor veya kaybolabiliyor temp yok ise sql çalışmaz hata verir geçici dosyaları oraya çıkardığı için örnek bu umarım faydalı olmuştur
Edited by milano88
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...