General discussion

Locked

Problem with update statement

By Arati ·
I have one table in sql, Defined as follows.
CREATE TABLE [dbo].[field_detail] (
[app_id] [numeric](18, 0) NOT NULL ,
[fieldnm] [varchar] (50) NULL ,
[field_web] [varchar] (50) NULL ,
[bus_type] [varchar] (50) NULL ,
[type_of_act] [varchar] (50) NULL ,
[no_of_catagory] [numeric](18, 0) NULL ,
[fields_no] [numeric](18, 0) NULL ,
[field_id] [int] IDENTITY (1, 1) NOT NULL
)
when I insert data from asp page it inserts the date but update statement is not working.


strSQL="insert into field_detail values(" & session("app_no") & ",'" & nmfield & "','" & fiweb & "','" & busntype & "','" & actitype & "'," & noofcat & "," & fieldno & ")"
db.Execute strsql
Response.Write("record is inserted & app_no = " & session("app_no"))
else
strsql ="update field_detail set fieldnm ='" & nmfield & "',field_web ='" & fiweb & "',bus_type ='" & busntype & "',type_of_act ='" & actitype & "',no_of_catagory =" & noofcat & " where app_id =" & zz & " and fields_no =" & b & ""
Response.Write strsql
db.Execute strSQL

Please reply

This conversation is currently closed to new comments.

7 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Problem with update statement

by sl-campbell In reply to Problem with update state ...

In the WHERE section of the UPDATE statement you are missing the single quotes around the criteria.

& " where app_id ='" & zz & "' and fields_no ='" & b & "'"

Collapse -

Problem with update statement

by sl-campbell In reply to Problem with update state ...

That is if app_id and fields_no are not numeric fields, and if they are, then values must be either whole numbers, or decimal numbers in US format with-out quotations, or decimal numbers in some foreign format with quotations.

Collapse -

Problem with update statement

by RRV In reply to Problem with update state ...

in Where condition fields_No does not start with single quote or should not have closing quote depending on the data type. Please mention error returned unless otherwise it is hard to determine the error.

Collapse -

Problem with update statement

by Arati In reply to Problem with update state ...

rvlion

the error is caused during runtime & message is as follows

Microsoft OLE DB Provider for SQL Server error '80040e31'

Timeout expired

/member/membreg3.asp, line 70

arati

Collapse -

Problem with update statement

by MedievalDude In reply to Problem with update state ...

Here's a tip to help you debug this thing. Comment out your "db.Execute strSQL" lines, and if you have any code after the "Response.Write strSQL", do a Response.End (so that the page stops right after spitting out strSQL). Then load your page. What you should see are the lines of SQL code that your page is going to execute through your database connection. That in itself may be helpful enough to you when you see it all laid out. If not, open up Query Analyzer and copy/paste in what your page spit out. Then run it for a more descriptive error that your web browser doesn't give you. If it's a page timeout, check to see how long those SQL statements take to run. If it's more than a minute, I would suggest perhaps setting up a job to execute a stored procedure that runs those statements. Otherwise, even if you up the timeout allotment for pages, users may get frantic when the page just sits there trying to load, and frantic users sometimes do rash things...

Collapse -

Problem with update statement

by MedievalDude In reply to Problem with update state ...

Have you tried to pick through the page as I suggested in my email? Work with small chunks of the code until you pinpoint the problem. Let me know how it's going, or if you have more questions.

Collapse -

Problem with update statement

by Arati In reply to Problem with update state ...

MedievalDude

as you suggest i tried in quarry analyser it works & take 1 second & so.But problem remain same when we tried from IE.

arati

Back to Web Development Forum
7 total posts (Page 1 of 1)  

Related Forums