why a form bound to ADO recordset from DB2 is readonly


B

Bula

I created a form bound to ADO recordset containing data from DB2
database, but the form is readonly. How can I make the form editable?

Steps:

--Create a form with 4 labels, and 4 text boxes: label 1, label2,
label3, label4, text1, text2, text3, text4.

--Put the following code to the form's open event:

Private Sub Form_Open(Cancel As Integer)
'create an ado connection instance and set its properties

Dim myconnection As ADODB.Connection
Set myconnection = New ADODB.Connection

Dim str As String
str = "Data Provider=IBMDADB2;DSN=sample;User
ID=MyuserID;Password=mypw;"
With myconnection
.Provider = "MSDataShape"
.CursorLocation = adUseClient
.ConnectionString = str
.Open
End With

'create an ado recordset and set its properties
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

With rs
Set .ActiveConnection = myconnection
.Source = "SELECT * FROM admin.staff"
.LockType = adLockOptimistic
.CursorType = adOpenSatic
.Open
End With

'set the form's data source to the ado recordset
Set Me.Recordset = rs
Me.UniqueTable = "staff1"
'bind form controls to recordset fields
Dim x As Integer
For x = 1 To 4
Me.Controls("Label" & x).Caption = rs.Fields(x - 1).Name
Me.Controls("Text" & x).ControlSource = rs.Fields(x - 1).Name
Next
End Sub
 
Ad

Advertisements

S

Stefan Hoffmann

hi,
I created a form bound to ADO recordset containing data from DB2
database, but the form is readonly. How can I make the form editable?
str = "Data Provider=IBMDADB2;DSN=sample;User
ID=MyuserID;Password=mypw;"
With myconnection
.Provider = "MSDataShape"
Sure that the MSDataShape provider is the correct one?


mfG
--> stefan <--
 
B

Bula

Thank you Stefan.

If we delete the MSDataShape provider, the result is the same.

Bula

Stefan Hoffmann wrote:
 
S

Stefan Hoffmann

hi,
If we delete the MSDataShape provider, the result is the same.
Link the table manually in the database window. If the linked table is
updateable, then use the connect string of this table.


mfG
--> stefan <--
 
Ad

Advertisements

B

Brendan Reynolds

The code you posted in your original post in this thread includes the
following line ...

.CursorType = adOpenSatic

If that is your actual code, and not just a typo in the newsgroup post, then
you have misspelled adOpenStatic.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top