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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help updating records

Status
Not open for further replies.

dvannoy

MIS
Joined
May 4, 2001
Messages
2,765
Location
US
I am pretty new to SQL server so i need some help..
I am trying to update records in DB table. I can connect and scroll through the record set. delete records etc.. but i cannot update records..

i've tryed rs.update
when i try the rs.update i get an error message and debug goes to my .open command.

also tryed "UPDATE * from tblname"

can someone help me out.

Thanks in advance DVannoy
A+,Network+,CNA
dvannoy@onyxes.com
 
see the syntax of UPDATE statement

UPDATE tablename SET fieldname = 'value'
WHERE condition
 
OK..what if i am scrolling through a recordset and decide to make changes say to someones lastname. then i want that record to be updated. then scroll through the recordset and change someones location...see i need the current record to be updated. i will never know what fields i will change.

Thanks DVannoy
A+,Network+,CNA
dvannoy@onyxes.com
 
This is what i have so far...

SetRS "UPDATE tblusers WHERE (firstname, lastname, ipaddress, location, ModelNo, SerialNo, Memory, ConType) VALUES ('" & txtFirstName.Text & "','" & txtLastName.Text & "','" & txtIpAddress.Text & "','" & cmbLocation.Text & "' ,'" & cmbModel.Text & "' ,'" & txtSerialNo.Text & "' ,'" & txtMemory.Text & "' ,'" & cmbConnectionType.Text & "')"

SetRS code below

Public Sub SetRS(SQL)

Set rs = New ADODB.Recordset

With rs
.ActiveConnection = con
.Source = SQL
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Open

End With


End Sub


it gives me an error and highlights .Open

DVannoy
A+,Network+,CNA
dvannoy@onyxes.com
 
Instead of using the recordset once you have the Update String that you need use Con.Execute SQL to execute the update statement and then refresh your recordset.
 
I still get an error in update syntax. it points to Con.Execute SQL

I must be using con.execute sql wrong..

DVannoy
A+,Network+,CNA
dvannoy@onyxes.com
 
I think the update string is wrong I think it needs to be like the following general format

Update tablename Set field1 = value, field2 = value, field3 = value, etc..... Where field1 = value, field2 = value, field3 = value.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top