Bosna i Hercegovina


switch Lista naslova:

#1 04.03.2014-23:09
zxz Online
Administrator
Registrovan/a od: 03.02.2009-16:22
Komentari: 8,809


Subject: Ado Primjeri*
U ovoj temi su dati primjeri za ado konekciju na bazu.
Primjeri si radjeni sa msado25.tlb.
Pozdrav
↑  ↓

#2 04.03.2014-23:10
zxz Online
Administrator
Registrovan/a od: 03.02.2009-16:22
Komentari: 8,809


Subject: Lista tabela
Procedura koja iscitava sve tabele u bazi.
DownloadIzvorni kod (Visual Basic):
  1. Function ListaTabela()
  2.     'Lista tabela
  3.    Dim cn As ADODB.Connection
  4.     Dim rs As ADODB.Recordset
  5.     Dim I As Integer
  6.    
  7.     Set cn = CurrentProject.Connection
  8.     Set rs = cn.OpenSchema(adSchemaTables, Array(Empty, Empty, Empty, "TABLE"))
  9.     Do While Not rs.EOF
  10.         Debug.Print rs.Fields("TABLE_NAME").Value
  11.         rs.MoveNext
  12.     Loop
  13.     rs.Close
  14.    
  15.     Set rs = Nothing
  16.     Set cn = Nothing
  17. End Function

Pozdrav
↑  ↓

#3 04.03.2014-23:16
zxz Online
Administrator
Registrovan/a od: 03.02.2009-16:22
Komentari: 8,809


Subject: Rekordset ado
Primjer otvaranja rekordseta sa ado konekcijom.
DownloadIzvorni kod (Visual Basic):
  1. Function AdoRekordset()
  2.     'Primjer otvaranja  rekordseta sa ado
  3.    Dim rs As New ADODB.Recordset
  4.     Dim strSql As String
  5.    
  6.     strSql = "SELECT ImePolja FROM ImeTabele;"
  7.     rs.Open strSql, CurrentProject.Connection
  8.    
  9.     Do While Not rs.EOF
  10.         Debug.Print rs!ImePolja
  11.         rs.MoveNext
  12.     Loop
  13.    
  14.     rs.Close
  15.     Set rs = Nothing
  16. End Function

Pozdrav
↑  ↓

#4 04.03.2014-23:22
zxz Online
Administrator
Registrovan/a od: 03.02.2009-16:22
Komentari: 8,809


Subject: Create View ado
Kreiranje Query-a ili Create View kako vam je lakse.

DownloadIzvorni kod (Visual Basic):
  1. Function CreateQuery()
  2.     'Kreiranje Query-a
  3.    Dim cn As ADODB.Connection
  4.     Dim strSql As String
  5.    
  6.     strSql = "CREATE VIEW MojQuery AS SELECT ImeTabele.* FROM ImeTabele;"
  7.     Set cn = CurrentProject.Connection
  8.     cn.Execute strSql
  9.    
  10.     MsgBox "Querty je kreiran"
  11.     Set cn = Nothing
  12. End Function

Pozdrav
↑  ↓

#5 04.03.2014-23:41
zxz Online
Administrator
Registrovan/a od: 03.02.2009-16:22
Komentari: 8,809


Subject: Izmjena podataka u tabeli
Ova procedura vrsi izmjenu podataka u tabeli.
Tabela treba da se zove Artikli te ako nije tako promijenite a polje se zove ImeArtikla.

DownloadIzvorni kod (Visual Basic):
  1. Function IzmijeniPodatak()
  2.     'Izmjena podataka
  3.    Dim cn As ADODB.Connection
  4.     Dim strSql As String
  5.     Dim lngKt As Long
  6.    
  7.     Set cn = CurrentProject.Connection
  8.     strSql = "UPDATE Artikli SET ImeArtikla = 'Nesto' WHERE ImeArtikla='aaaaa';"
  9.    
  10.     cn.Execute strSql, lngKt
  11.    
  12.     Set cn = Nothing
  13.     TestBnot = lngKt
  14. End Function

Pozdrav
↑  ↓

#6 07.03.2014-12:07
zxz Online
Administrator
Registrovan/a od: 03.02.2009-16:22
Komentari: 8,809


Subject: Ko je logovan na bazu.
DownloadIzvorni kod (Visual Basic):
  1. Function Logovani()
  2.     Dim cn As New ADODB.Connection
  3.     Dim rs As New ADODB.Recordset
  4.     Dim i, j As Long
  5.  
  6.     cn.Provider = "Microsoft.Jet.OLEDB.4.0"
  7.     'cn.Open "Data Source=C:\Data\Northwind2003.mdb" ' ako se radi o drugoj bazi i onda set netreba
  8. Set cn = CurrentProject.Connection
  9.     Set rs = cn.OpenSchema(adSchemaProviderSpecific, , "{947bb102-5d43-11d1-bdbf-00c04fb92675}")
  10.  
  11.     While Not rs.EOF
  12.         Debug.Print "Ime compa: " & rs.Fields(0), "Login Ime: "; rs.Fields(1), "Login: "; rs.Fields(2)
  13.         rs.MoveNext
  14.     Wend
  15. End Function

Pozdrav
↑  ↓

Stranice (1): 1


All times are GMT +01:00. Current time: 17.01.2017-11:55.