Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Access i tabele

[es] :: Access :: Access i tabele

[ Pregleda: 4323 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

DjordjeRd
Đorđe Radomirović
Kablovski pristupni uređaji, Telekom
Srbija
NP, 43.1370N, 20.5120E

Član broj: 1412
Poruke: 574
*.telekom.yu

Sajt: picasaweb.google.com/djor..


+4 Profil

icon Access i tabele18.09.2003. u 17:47 - pre 250 meseci
Kako da testiram da li postoji neka tabela u Access bazi? Npr. lupam:

...
If Exists t0309 Then
...
c000 lda #$33
c002 sta $0400
c005 lda #$37
c007 sta $0401
c00a lda #$21
c00c sta $0402
c00f rts

sys 49152
 
Odgovor na temu

mladenovicz
Zeljko Mladenovic
Xoran Technologies, Inc., Ann Arbor, MI,
USA / Software Engineer
Ann Arbor, MI, USA

Član broj: 6598
Poruke: 2065
*.yubc.net

Jabber: mladenovicz@elitesecurity.org
ICQ: 95144142
Sajt: yubc.net/~mz


Profil

icon Re: Access i tabele18.09.2003. u 18:11 - pre 250 meseci
VB kod za rad sa ADOm

Code:

Public Function TableExistsADO( _
    vstrDatabaseName As String, _
    vstrTableName As String _
) As Boolean
Const cCnnStr   As String = "PROVIDER=Microsoft.Jet.OLEDB.3.51;Data Source="

Dim cnn         As ADODB.Connection
Dim rst         As ADODB.Recordset

    On Error GoTo Proc_Err

    Set cnn = New ADODB.Connection
    cnn.ConnectionString = cCnnStr & vstrDatabaseName
    cnn.Open
    Set rst = New ADODB.Recordset
    rst.Open "SELECT * FROM " & vstrTableName, cnn

    TableExistsADO = True
    
Proc_Exit:
    ' close and destroy recordset and connection object
    If Not rst Is Nothing Then
        If rst.State <> adStateClosed Then rst.Close
        Set rst = Nothing
    End If
    
    If Not cnn Is Nothing Then
        If cnn.State <> adStateClosed Then cnn.Close
        Set cnn = Nothing
    End If
    Exit Function
Proc_Err:
    If Err.Number = -2147217865 Then    ' ADO returns this error code if table doesn't exist
        TableExistsADO = False
        Resume Proc_Exit
    End If
End Function


Kad koristis DAO, cini mi se da postoji kolekcija Tables ili tako nesto, ne mogu da se setim, i ides kroz kolekciju i trazis onu koja ti treba
 
Odgovor na temu

DjordjeRd
Đorđe Radomirović
Kablovski pristupni uređaji, Telekom
Srbija
NP, 43.1370N, 20.5120E

Član broj: 1412
Poruke: 574
*.telekom.yu

Sajt: picasaweb.google.com/djor..


+4 Profil

icon Re: Access i tabele18.09.2003. u 18:14 - pre 250 meseci
Hvala najlepše na brzom i preciznom odgovoru. ADO je, kao i uvek, više nego dovoljan. Sve je odmah proradilo...
c000 lda #$33
c002 sta $0400
c005 lda #$37
c007 sta $0401
c00a lda #$21
c00c sta $0402
c00f rts

sys 49152
 
Odgovor na temu

DjordjeRd
Đorđe Radomirović
Kablovski pristupni uređaji, Telekom
Srbija
NP, 43.1370N, 20.5120E

Član broj: 1412
Poruke: 574
*.telekom.yu

Sajt: picasaweb.google.com/djor..


+4 Profil

icon Re: Access i tabele18.09.2003. u 19:08 - pre 250 meseci
Eto, iskopala se i DAO varijanta:

'********************************************************
' FUNCTION: IsTableQuery()
'
' PURPOSE: Determine if a table or query exists.
'
' ARGUMENTS:
' DbName: The name of the database. If the database name
' is "" the current database is used.
' TName: The name of a table or query.
'
' RETURNS: True (it exists) or False (it does not exist).
'
'********************************************************

Function IsTableQuery(DbName As String, TName As String) As Integer

Dim Db As DAO.Database, Found As Integer, Test As String
Const NAME_NOT_IN_COLLECTION = 3265

' Assume the table or query does not exist.
Found = False

' Trap for any errors.
On Error Resume Next

' If the database name is empty...
If Trim$(DbName) = "" Then
' ...then set Db to the current Db.
Set Db = CurrentDb()
Else
' Otherwise, set Db to the specified open database.
Set Db = DBEngine.Workspaces(0).OpenDatabase(DbName)

' See if an error occurred.
If Err Then
MsgBox "Could not find database to open: " & DbName
IsTableQuery = False
Exit Function
End If
End If

' See if the name is in the Tables collection.
Test = Db.TableDefs(TName).Name
If Err <> NAME_NOT_IN_COLLECTION Then Found = True

' Reset the error variable.
Err = 0

' See if the name is in the Queries collection.
Test = Db.QueryDefs(TName$).Name
If Err <> NAME_NOT_IN_COLLECTION Then Found = True

Db.Close

IsTableQuery = Found

End Function

c000 lda #$33
c002 sta $0400
c005 lda #$37
c007 sta $0401
c00a lda #$21
c00c sta $0402
c00f rts

sys 49152
 
Odgovor na temu

[es] :: Access :: Access i tabele

[ Pregleda: 4323 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.