This is the code i m using for updating table,which the user is entering through textbox in vb form
Con.Execute "update Details set 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 & "' and PHONE_NO='" & txtPhno.Text & "' where PS_No=" & Trim(txtPSNo.Text) & ""

This is the database i created,at the time of updastion it is givn err
PS_No number(long int)
NAME text
DT_OF_BTH date/time short date
DT_OF_JOING date/time short date
SALARY_ACC number (double,fixed)
REMBSMNT_ACC number (double,fixed)
PHONE_NO number (double,general)

Recommended Answers

All 8 Replies

Couple of possibilities

Lets start with the date. Are you sure it is a properly formatted date?
What DBMS (Access, SQL, dBase)?
Each handle dates just a little bit differently. If you are using Access then go to the query analyzer, build your insert string there and see what characters it uses to wrap around the date field. Take that knowledge and apply it to your update string.

Now, onto salary. You are wrapping a number with single ticks ' so you are telling your database to update a number with a text string and it looks like you are doing the same for the other number fields in your statement.

Other worries:
I don't see any validation code, meaning are you sure the information that the use is entering is valid. i.e. the user is not trying to update the salary field with a string like "'Fifty thousand dollars and no cents'"

Good Luck

For nw i m working within constrainsts only,like i m just changing the sequence of digits to see that is it working or not,but its not giving me the desiered result

I am using Access database as backend

You need to format the date to proper format before pasing the same to database.

I am sending the data in same format as i have mentioned in my database,n in case of phone no,i my jst chnging the order,bt its nt wrkn..........:(

Access does not like it when you pass up a string for a number field and that is what you are doing when you wrap your numbers with quotes.

So how do i do this,in which format i need to pass the values,can u gv an example,or just change my code the way it is required

update Details set 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 & " and PHONE_NO=" & txtPhno.Text & " where PS_No=" & Trim(txtPSNo.Text)

I think that should do it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.