vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| All, I am working off of the vb6 sample given in the psqlODBC doc that accompanies the odbc driver. My issue is, when I am displaying the rs.Cursortype, it is reading 3, however this is not what was requested. Shouldn't this be 2? Thank You, Joseph Armbruster Dim cn As New adodb.Connection Dim rs As New adodb.Recordset cn.Open "DSN=test_post;UID=postgres;PWD=acupostgres;Databa se=vbtest" rs.CursorType = adOpenDynamic rs.LockType = adLockOptimistic rs.CursorLocation = adUseServer rs.Open "SELECT id, data FROM vbtest", cn, adOpenDynamic, adLockOptimistic MsgBox "AdoEnums.CursorType.DYNAMIC = " & adodb.CursorTypeEnum.adOpenDynamic MsgBox "rs.CursorType = " & rs.CursorType & vbCrLf & "rs.CursorLocation = " & rs.CursorLocation While Not rs.EOF Debug.Print rs!id & ": " & rs!Data rs.MoveNext Wend rs.AddNew rs!id = 76 rs!Data = "More random data" rs.Update cn.Execute "INSERT INTO vbtest (id, data) VALUES (23, 'Some random data');" rs.Update If rs.State <> adStateClosed Then rs.Close Set rs = Nothing If cn.State <> adStateClosed Then cn.Close Set cn = Nothing |
| ||||
| I was under the impression that psqlODBC does not support server side cursors. Therefore the correct way to retrieve data is to use a client side cursor (adUseClient). This is inline with a "disconnected" model that returns all the requested records immediately, instead of waiting for the client to cursor through them. This also is supposed to allow a more immediate release of the connection, ultimately providing greater scalability. (Is scalability still a buzz-word?). BTW your sample specifies a LockType in two places. It's ok, but you don't really need that. I think the one on the rs.Open line is good enough. Note: adUseServer=2 adUseClient=3 Joseph Armbruster wrote: > All, > > I am working off of the vb6 sample given in the psqlODBC doc that > accompanies the odbc driver. My issue is, when I am displaying the > rs.Cursortype, it is reading 3, however this is not what was requested. > Shouldn't this be 2? > > Thank You, > Joseph Armbruster > > Dim cn As New adodb.Connection > Dim rs As New adodb.Recordset > > cn.Open "DSN=test_post;UID=postgres;PWD=acupostgres;Databa se=vbtest" > > rs.CursorType = adOpenDynamic > rs.LockType = adLockOptimistic > rs.CursorLocation = adUseServer > rs.Open "SELECT id, data FROM vbtest", cn, adOpenDynamic, adLockOptimistic > > MsgBox "AdoEnums.CursorType.DYNAMIC = " & adodb.CursorTypeEnum.adOpenDynamic > MsgBox "rs.CursorType = " & rs.CursorType & vbCrLf & "rs.CursorLocation = " > & rs.CursorLocation > > While Not rs.EOF > Debug.Print rs!id & ": " & rs!Data > rs.MoveNext > Wend > > rs.AddNew > rs!id = 76 > rs!Data = "More random data" > > rs.Update > > cn.Execute "INSERT INTO vbtest (id, data) VALUES (23, 'Some random data');" > rs.Update > > > If rs.State <> adStateClosed Then rs.Close > Set rs = Nothing > If cn.State <> adStateClosed Then cn.Close > Set cn = Nothing > ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster |