January 23, 2008 at 9:32 am
Below is what I had started but I know I'm going in the wrong direction so I figured I'd better ask for help. Here's what I need. iAsmtId and sQuest are passed to this page from the previous page while sJustify is the value from and the name of the textarea on this page. I need check the db for an instance of the current iAsmtID and sQuest. If it exist then it should display in the text area for viewing and should be allowed to be updated with the click of the submit. The most important part, though is that if there is not instance then it should insert a new record to the table when the user clicks submit with the current values for iAsmtID, sQuest, and sJustify. Any help greatly appreciated. Thanks.
<%
dim sJustify
iAsmtID = request.QueryString("iAsmtID")
sQuest = request.QueryString("sQuest")
'sJustify = request.Form("sJustify")
'Set Conn = Server.CreateObject("ADODB.Connection")
'Conn.open My_Conn
'str = "SELECT * FROM Checklist_Justify WHERE iAsmtID="&iAsmtID
'str = "INSERT INTO Checklist_Justify (iAsmtID, sQuest, sJustify) VALUES ("&iAsmtID&"," &sQuest&",'Testing')"
'response.Write(str)
'conn.execute(str)
'Conn.close
%>
January 23, 2008 at 9:46 am
<%
dim sJustify
iAsmtID = request.QueryString("iAsmtID")
sQuest = request.QueryString("sQuest")
'sJustify = request.Form("sJustify")
'Set Conn = Server.CreateObject("ADODB.Connection")
' Conn.open My_Conn
'str = "if not exists (SELECT * FROM Checklist_Justify WHERE iAsmtID="&iAsmtID&")"
'str = "INSERT INTO Checklist_Justify (iAsmtID, sQuest, sJustify) VALUES ("&iAsmtID&"," &sQuest&",'Testing')"
'response.Write(str)
'conn.execute(str)
'Conn.close
%>
January 23, 2008 at 11:53 am
My ASP is rusty but ....
Ray M (1/23/2008)
'str = "if not exists (SELECT * FROM Checklist_Justify WHERE iAsmtID="&iAsmtID&")"'str = "INSERT INTO Checklist_Justify (iAsmtID, sQuest, sJustify) VALUES ("&iAsmtID&","&sQuest&",'Testing')"
Unless I'm very mistaken, the second assignment to str will overwrite the first. Perhaps
'str = "if not exists (SELECT * FROM Checklist_Justify WHERE iAsmtID="&iAsmtID&")" + vbcrlf
'str = str + " INSERT INTO Checklist_Justify (iAsmtID, sQuest, sJustify) VALUES ("&iAsmtID&","&sQuest&",'Testing')"
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply