Problem when accessing a SQL Anywhere DB from within VB 5 
Author Message
 Problem when accessing a SQL Anywhere DB from within VB 5

Hello,

I'm wondering if somebody could help this VB-dummy with the following
problem : I want to access in batch (read and write) a SQL Anywhere database
(release 5) from within a VB application.  Below is a small sample
application which shows how I approached this. The problem which I
experience is that, despite the fact that the db is opened in update mode
(see my debug output), I can read the data but not update. The error message
I receive is 3027 : "Can't update. Database or object is read-only". I can
access the same database with any other, e.g. PowerBuilder, applications.

Thanks in advance for your help,
Ivan DE BURCHGRAEVE

THE DEBUG OUTPUT
Connection properties for Connection1:
    Connect = ODBC;DSN=bgdb1p2;UID=dba;PWD=sql;Database=bgdb1p2
    Database[.Name] = Connection1
    Name = Connection1
    QueryTimeout = 30
    RecordsAffected = 0
    StillExecuting = False
    Transactions = True
    Updatable = True
contents of field 1 in table = ZEELAAN

THE FAILING PROGRAM :

Dim wrkODBC As Workspace
Dim wrkCon As Connection
Dim conLoop As Connection
Dim wrkTab As Recordset

' Create ODBCDirect Workspace object.
Set wrkODBC = CreateWorkspace("NewODBCWorkspace", _
                              "admin", "", dbUseODBC)

' Open Connection object using supplied information in
' the connect string. If this information were
' insufficient, you could trap for an error rather than
' go to an ODBC Driver Manager dialog box.
MsgBox "Opening Connection1..."
Set wrkCon = wrkODBC.OpenConnection("Connection1", _
        dbDriverNoPrompt, ,
"ODBC;DATABASE=bgdb1p2;UID=dba;PWD=sql;DSN=bgdb1p2")

' Enumerate the Connections collection.
For Each conLoop In wrkODBC.Connections
   Debug.Print "Connection properties for " & conLoop.Name & ":"

   With conLoop
        ' Print property values by explicitly calling each
        ' Property object; the Connection object does not
        ' support a Properties collection.
        Debug.Print "    Connect = " & .Connect
        ' Property actually returns a Database object.
        Debug.Print "    Database[.Name] = " & _
            .Database.Name
        Debug.Print "    Name = " & .Name
        Debug.Print "    QueryTimeout = " & .QueryTimeout
        Debug.Print "    RecordsAffected = " & _
            .RecordsAffected
        Debug.Print "    StillExecuting = " & _
            .StillExecuting
        Debug.Print "    Transactions = " & .Transactions
        Debug.Print "    Updatable = " & .Updatable
    End With

Next conLoop

Set wrkTab = wrkCon.OpenRecordset("SELECT * from SYS_STRATEN", _
        dbOpenDynaset)

Debug.Print "contents of field 1 in table = "; wrkTab!db_sys_str_id

wrkTab.Edit
wrkTab!db_sys_str_id = "hello world"
Debug.Print "change contents of field 1 in table = "; wrkTab!db_sys_str_id
wrkTab.Update

wrkTab.Close
wrkCon.Close
wrkODBC.Close

Unload Me



Thu, 11 Apr 2002 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Application Development: MS-Access, Visual Basic, SQL Server, SQL Anywhere

2. Problem running VB after moving db from Access to SQL server

3. Create SQL Server DB from within VB

4. Visual Basic App using Foxpro DB vs Access DB vs SQL Server DB

5. Visual Basic App using Foxpro DB vs Access DB vs SQL Server DB

6. creating access db within vb 3.0

7. Open Access DB within VB and pass to

8. Opening a db within Access VB code

9. Access 97 <-> Sybase SQL Anywhere

10. sybase SQL anywhere Access

11. Sybase SQL Anywhere Problem

12. Newbie Problem with SQL Anywhere

 

 
Powered by phpBB® Forum Software