Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

str2field

Status
Not open for further replies.

myasin78

Programmer
Jan 26, 2004
50
US
I am trying to update DB using ADO Recordset.
Rs1.addnew
with Rs1
!name = str2field(txtname)
end with
Rs1.update

when i run this code i get function not defined.
do you know which library should i load to define this function " str2field".

thanks,

myasin78

 
Hi myasin78,

I have no idea where to find this function, but what does it do? You should be able to assign your string directly to the field ..

[blue]
Code:
!Name = txtName
[/blue]

Enjoy,
Tony

------------------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading FAQ222-2244 before you ask a question.
 
Hi tony,
I found that in a VB book, it supose to assign a string to a field record in DB.
 
After running this code i got an error
Object or provider is not capable of performing requesting operation.

link to this line: Rs1.AddNew

Dim id As Long, ssn As Long

Call clearAll

Rs1.AddNew
With Rs1
!name = txtname
!ssnno = txtssn
End With

Rs1.Update
 
Guessing you've opened a recordset that's not updateable. It sometimes help if we see the complete code.

That said, look into the cursor type of keyset and lock type optimistic. This doesn't help, please provide the complete code regarding the recordset.

Roy-Vidar
 
here is some of my code,
hope this will give an idea.
thanks,

Public Rs1 As New ADODB.Recordset
Public buffer As String
Public dbConn As New ADODB.Connection
Public strSQL As String


Private Sub Command1_Click()
buffer = "DSN=yamato;UID=user;PWD=mypwd"
dbConn.Open buffer
strSQL = "SELECT name,id FROM table"
Rs1.Open strSQL, dbConn, adOpenDynamic
End Sub

Private Sub cmdMoveNext_Click()

If dbConn.State Then 'check if DB is open
With Rs1
If Not .EOF Then
txtname.Text = Rs1.Fields(0)
txtssn.Text = Rs1.Fields(1)
listbox.AddItem Rs1.Fields(0)
.MoveNext
Else
MsgBox ("End of File")
.MoveLast
End If
End With
Else
MsgBox ("DB Is Closed")
End If

End Sub

Private Sub cmdInsert_Click()
'insert data into the database
Dim name As string, ssn As Long

Call clearAll
Rs1.AddNew
With Rs1
!name = txtoutput
!ssn = txtpatent
End With
Rs1.Update
End Sub



 
Try this:
Rs1.Open strSQL, dbConn, adOpenDynamic, adLockOptimistic
in your Command1_Click procedure.


Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
thanks PHV,

it complains that can't insert null into database.
i actully hard coded the variable to just tested.

i got the error on this line: Rs1.update

any idea

 
Seems your table has more than 2 columns ...

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top