duke1000
November 6th, 1999, 12:48 PM
Hi :-)
I would like to know how to insert a new row in a table with RDO programming ? Should I use the INSERT TO (SQL) or the .AddNew method. I tried both, without success.
Here's my code :
--------------------
Option Explicit
Dim conn As rdoConnection
Dim qy As rdoQuery
Dim rs As rdoResultset
Private Sub Form_Load()
Set conn = New rdoConnection
With conn
.Connect = "dsn=vernon"
.EstablishConnection rdDriverNoPrompt, True
End With
Set qy = New rdoQuery
qy.SQL = "select * from authors"
Set qy.ActiveConnection = conn
Set rs = qy.OpenResultset(rdOpenKeyset)
End Sub
Private Sub B_Add_Click()
' Here is How I use the .AddNew method
With rs
.AddNew
!au_id = T_au_id
!au_lname = T_au_lname
!au_fname = T_au_fname
!contract = T_contract
!address = T_address
!city = T_city
!state = T_state
!zip = T_zip
!phone = T_phone
.Update
End With
' And here is how I use the INSERT TO (SQL)
conn.BeginTrans
qy.Execute " insert into authors " _
& "(au_id, au_lname, au_fname, contract, address, city, state, zip, phone) values " _
& "(T_au_id.Text, T_au_lname.Text, T_au_fname.Text, T_contract.Text, T_address.Text, T_city.Text, T_state.Text, T_zip.Text, T_phone.Text);"
conn.CommitTrans
End Sub
---------------------------------
Thank you so much ! :o)
Duke1000 :-)
I would like to know how to insert a new row in a table with RDO programming ? Should I use the INSERT TO (SQL) or the .AddNew method. I tried both, without success.
Here's my code :
--------------------
Option Explicit
Dim conn As rdoConnection
Dim qy As rdoQuery
Dim rs As rdoResultset
Private Sub Form_Load()
Set conn = New rdoConnection
With conn
.Connect = "dsn=vernon"
.EstablishConnection rdDriverNoPrompt, True
End With
Set qy = New rdoQuery
qy.SQL = "select * from authors"
Set qy.ActiveConnection = conn
Set rs = qy.OpenResultset(rdOpenKeyset)
End Sub
Private Sub B_Add_Click()
' Here is How I use the .AddNew method
With rs
.AddNew
!au_id = T_au_id
!au_lname = T_au_lname
!au_fname = T_au_fname
!contract = T_contract
!address = T_address
!city = T_city
!state = T_state
!zip = T_zip
!phone = T_phone
.Update
End With
' And here is how I use the INSERT TO (SQL)
conn.BeginTrans
qy.Execute " insert into authors " _
& "(au_id, au_lname, au_fname, contract, address, city, state, zip, phone) values " _
& "(T_au_id.Text, T_au_lname.Text, T_au_fname.Text, T_contract.Text, T_address.Text, T_city.Text, T_state.Text, T_zip.Text, T_phone.Text);"
conn.CommitTrans
End Sub
---------------------------------
Thank you so much ! :o)
Duke1000 :-)