Jump to content

Mssql Bağlantısı Nasıl Yapılır ?


muratboy31
 Share

Recommended Posts

local conn = luacom.CreateObject("ADODB.Connection")

if conn then
 conn:Open("Driver={SQL Server}; Server=localhost; DataBase=Customers; Uid=sa; Pwd=123456")
 local rs = conn:Execute("SELECT * FROM user")
 Grid.SetColumnCount("Grid1", rs.Fields.Count);
 local r = 0
    
 while not rs.EOF do
  
  r = r + 1
  Grid.SetRowCount("Grid1", r+1);
  for i = 0, rs.Fields.Count - 1 do
   
   local fld = rs.Fields:Item(i)
   if fld and fld.Value then
    Grid.SetCellText("Grid1", r, i, fld.Value, true);
   end
  end
  rs:MoveNext()
 end
 
 rs:Close()
 
 Grid.SetRedraw("Grid1", true)
 
end

bu kodda bağlantı satırında hata veriyor , nerde yanlış yapıyprum acaba ?

Link to comment
Share on other sites

Veri tabanındaki tablo bu ;

2rq0i38.jpg

 

hatayı burada veriyormuş bağlantıda değil, tüm alanları listelemiyor nedense !

 

Grid.SetCellText("Grid1", r, i, fld.Value, true);

 

 

kullandığım kod bu ;

 

local conn = luacom.CreateObject("ADODB.Connection")

if conn then
 conn:Open("Driver={SQL Server}; Server=192.168.1.3; DataBase=Forwin2013; Uid=sa; Pwd=123456")
 local rs = conn:Execute("SELECT * FROM KNT_SAYAC")
 Grid.SetColumnCount("Grid1", rs.Fields.Count);
 local r = 0
   
 while not rs.EOF do
 
  r = r + 1
  Grid.SetRowCount("Grid1", r+1);
  for i = 0, rs.Fields.Count - 1 do
  
   local fld = rs.Fields:Item(i)
   if fld and fld.Value then
    Grid.SetCellText("Grid1", r, i, fld.Value, true);
   end
  end
  rs:MoveNext()
 end
 
 rs:Close()
 
 Grid.SetRedraw("Grid1", true)
 
end

Link to comment
Share on other sites

Mssql de nasıl tablo oluşturabilirim acaba ? bu şekilde denedim olmadı ...

 

local conn = luacom.CreateObject("ADODB.Connection")

if conn then
 conn:Open("Driver={SQL Server}; Server=192.168.1.3; DataBase=Forwin2013; Uid=sa; Pwd=123456")
 local rs = conn:Execute("SELECT * FROM KNT_CIKIS")

while rs do
TreeList.AddRow("Plugin1", rs.TRH1.."|"..rs.TRH2, nil, nil, nil);
end

Link to comment
Share on other sites

  • Editor
create table ogrenciler --Ogrenci tablo oluşturma sorgusu
(
ogrId int identity(1,1) primary key, --Birincil anahtar (primary key) ve otomatik artan(identity(1,1))
adi varchar(30),
soyadi varchar(30),
numara int,
cinsiyet varchar(5),
telefon char(11)
)
Link to comment
Share on other sites

aslında tam olarak bu değildi sorum yanlış anlattım sanırım...

 

Şöyle olması lazım yane ben mssql de bulunun bir tablodan veriyi alıp ams de şu şekilde bir table oluşturması;

 

local rs = conn:Execute("SELECT * FROM KNT_CIKIS")

while rs do
TreeList.AddRow("Plugin1", rs.TARIH1.."|"..rs.TARIH2.."|"..rs.TARIH3, nil, nil, nil);
end

 

bu sayede istediğim gibi kullanabilirim veriyi input yada başka bir obje ile...

Link to comment
Share on other sites

neden gridde 9 dan sonrası görünmüyor acaba ?

 

mmzu4w.jpg

 

kullandığım kod bu ;

Grid.SetCellText("Grid1", 0, 0, "Makbuz No", true);
Grid.SetCellText("Grid1", 0, 1, "Plaka", true);
Grid.SetCellText("Grid1", 0, 2, "Giriş Tarihi", true);
Grid.SetCellText("Grid1", 0, 3, "Çıkış Tarihi", true);
Grid.SetCellText("Grid1", 0, 4, "Dorse Plaka", true);
Grid.SetCellText("Grid1", 0, 5, "Müşteri", true);
Grid.SetCellText("Grid1", 0, 6, "Tartım 1", true);
Grid.SetCellText("Grid1", 0, 7, "Tartım 2", true);
Grid.SetCellText("Grid1", 0, 8, "Net", true);
Grid.SetCellText("Grid1", 0, 9, "Cins", true);
Grid.SetCellText("Grid1", 0, 10, "Açıklama", true);
Grid.SetCellText("Grid1", 0, 11, "Kullanıcı", true);

 

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...