how do i use update command in vb??
I need to make changes in the database from vb form,the changes made in the text box should be made in the database as well,this is the code i am using

Con.Execute "update Details set PS_No=" & Trim(txtPSNo.Text) & " and NAME=" & txtName.Text & " and DT_OF_BTH=" & txtDOB.Text & " and DT_OF_JOING=" & txtDOJ.Text & " and SALARY_ACC=" & txtAccountNo.Text & " and REMBSMNT_ACC=" & txtRmbr.Text & " where PS_No=" & Trim(txtPSNo.Text) & ""
the err is "Attribute cannot be set now"

This is the code for delete command i m using
Con.Execute "delete from Details where PS_No=" & Trim(txtPSNo.Text) & ""
This is deleting the data,but is giving me an err msg as well
The err is "Syntax err operator missing"

9 Years
Discussion Span
Last Post by javmedia

Could be your con string causing this too.
Hard to tell when I can't see the db.
Is this Access, Jet, MS SQL or other SQL92-SQL2000 compliant DBMS, with or without DNS or is it ADO called?

To me (being away from VB for over a year) the call seems obscure.

Consider MySQL version from VB

"UPDATE `Details` SET `col1Value`='StringHere', `col2Value`='StringHere', `col3Value`='StringHere'
 WHERE `IndexFld`='IDValue';"

No redundant AND's

Verify that your field names (columns) are accurately named.
Besides you cannot change attributes with an SQL update string unless you specify the attribute name to update rather than the default value of the field (column).


My connection is proper coz i m able to do save,search operation.........


Save, Search, Insert, Update and Delete operations all have the same con string. Changing attirbutes by altering a table definition is something different all together.

Read the helpfile on the section "TableDef"

From the help file for DAO for example... (VB5)

Sub TableDefX()

	Dim dbsNorthwind As Database
	Dim tdfNew As TableDef
	Dim tdfLoop As TableDef
	Dim prpLoop As Property

	Set dbsNorthwind = OpenDatabase("Northwind.mdb")

	' Create new TableDef object, append Field objects 
	' to its Fields collection, and append TableDef 
	' object to the TableDefs collection of the 
	' Database object.
	Set tdfNew = dbsNorthwind.CreateTableDef("NewTableDef")
	tdfNew.Fields.Append tdfNew.CreateField("Date", dbDate)

dbsNorthwind.TableDefs.Append tdfNew

	With dbsNorthwind
		Debug.Print .TableDefs.Count & _
			" TableDefs in " & .Name

		' Enumerate TableDefs collection.
		For Each tdfLoop In .TableDefs
			Debug.Print "    " & tdfLoop.Name
		Next tdfLoop

		With tdfNew
			Debug.Print "Properties of " & .Name

			' Enumerate Properties collection of new
			' TableDef object, only printing properties
			' with non-empty values.

For Each prpLoop In .Properties
				Debug.Print "    " & prpLoop.Name & " - " & _
					IIf(prpLoop = "", "[empty]", prpLoop)
			Next prpLoop

		End With

		' Delete new TableDef since this is a 
		' demonstration.
		.TableDefs.Delete tdfNew.Name
	End With

End Sub

PS / comatose just posted a nice sticky at the top of this section of threads with a help/intro to VB / Acess db's

Check your SQL queries though...
You have open ended entries.

First SQL query, eclose all strings in single quotes, not to deter from the use of double qoutes in code
Second SQL query, try ending it with a semi colon ; for proper ANSI SQL

That might help


Why complicate d code,whn ths can be done in a single line,i dnt want any loop,just want it plain and simple.......


Its not really complicated.
You can surely keep it in the single line format if its just one call, but I just wanted to point out the problem when simplfying by reducing line count in VB becomes more difficult to debug.

Also, I believe the key to the solution is the line's quotes (or lack thereof) as I said in the end.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.