Cinnamon
06-27-2002, 09:48 AM
Ok guys... I've included all of the project code this time. The goal of this project is to:
1) enter a record number
2) display the record image
**** 1 & 2 work great
3) enter index (a sentence) information
****I can enter text and click submit... but the record is not getting updated
4) update the record with the new index information
****this should happen in the "Sub SaveNow"
I've included the suggestions from the "editing a record" post. I really appreciate the help and comments. I'm learning alot and it's great to have people out there that push me in the right direction.
At this point I'm not getting any error messages. However, the database is not updating either. Also, I have a "Response.Write(newIndex)" line and nothing appears when executed. Here is my code... try not to laugh too hard!
Cinnamon
<%@ Language=VBScript %>
<%
Option Explicit
Dim cnnDB, strQuery, newIndex
Dim cnnDatabase, rstDatabase, dtbDatabase, SearchThis, ImagePath
If Request.QueryString("bSave")="True" Then
SaveNow
else
Dim strSomePic
strSomePic = Preview
response.write(strSomepic)
End if
%>
<%
Sub SaveNow()
On Error Resume Next
newIndex = Request.QueryString("Cindex")
Response.Write(newIndex)
set cnnDB=Server.CreateObject("ADODB.Connection")
cnnDB.Open "Driver=SQL Server;server=DIGITAL;database=gen_cards;uid=cinnamon;pwd=sinnamon"
strQuery = "UPDATE Cards SET entry='" & newIndex & "' WHERE [unique]=" & SearchThis & ";"
cnnDB.Execute(strQuery)
end sub
%>
<%
Function Preview()
SearchThis = CLng(Request.QueryString("iRecordId"))
Response.Write(SearchThis)
If IsNumeric(SearchThis) Then
cnnDatabase = "Driver=SQL Server;server=DIGITAL;database=gen_cards;uid=cinnamon;pwd=sinnamon"
Set rstDatabase=Server.CreateObject("ADODB.Recordset")
dtbDatabase = "SELECT * FROM Cards WHERE [unique]=" & SearchThis & ";"
rstDatabase.Open dtbDatabase, cnnDatabase, 3, 3
If NOT rstDatabase.EOF Then
ImagePath = rstDatabase.Fields("SQLpath")
Response.Write rstDatabase.Fields("SQLpath")
Response.Write rstDatabase.Fields("entry")
Preview = Imagepath
Else
Response.Write "Record not found"
End If
Else
Response.Write "Invalid input"
End If
End Function
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 2</title>
</head>
<body>
<img
src = ".<%= strSomePic %>"
width = "575"
height = "425"
/>
<br>
<form action="new_page_2.asp?bSave=True" method="post">
Enter index information:
<input type="text" name="Cindex"><br><br>
<input type="submit" value="Submit">
</form>
<p>
</body>
</html>
1) enter a record number
2) display the record image
**** 1 & 2 work great
3) enter index (a sentence) information
****I can enter text and click submit... but the record is not getting updated
4) update the record with the new index information
****this should happen in the "Sub SaveNow"
I've included the suggestions from the "editing a record" post. I really appreciate the help and comments. I'm learning alot and it's great to have people out there that push me in the right direction.
At this point I'm not getting any error messages. However, the database is not updating either. Also, I have a "Response.Write(newIndex)" line and nothing appears when executed. Here is my code... try not to laugh too hard!
Cinnamon
<%@ Language=VBScript %>
<%
Option Explicit
Dim cnnDB, strQuery, newIndex
Dim cnnDatabase, rstDatabase, dtbDatabase, SearchThis, ImagePath
If Request.QueryString("bSave")="True" Then
SaveNow
else
Dim strSomePic
strSomePic = Preview
response.write(strSomepic)
End if
%>
<%
Sub SaveNow()
On Error Resume Next
newIndex = Request.QueryString("Cindex")
Response.Write(newIndex)
set cnnDB=Server.CreateObject("ADODB.Connection")
cnnDB.Open "Driver=SQL Server;server=DIGITAL;database=gen_cards;uid=cinnamon;pwd=sinnamon"
strQuery = "UPDATE Cards SET entry='" & newIndex & "' WHERE [unique]=" & SearchThis & ";"
cnnDB.Execute(strQuery)
end sub
%>
<%
Function Preview()
SearchThis = CLng(Request.QueryString("iRecordId"))
Response.Write(SearchThis)
If IsNumeric(SearchThis) Then
cnnDatabase = "Driver=SQL Server;server=DIGITAL;database=gen_cards;uid=cinnamon;pwd=sinnamon"
Set rstDatabase=Server.CreateObject("ADODB.Recordset")
dtbDatabase = "SELECT * FROM Cards WHERE [unique]=" & SearchThis & ";"
rstDatabase.Open dtbDatabase, cnnDatabase, 3, 3
If NOT rstDatabase.EOF Then
ImagePath = rstDatabase.Fields("SQLpath")
Response.Write rstDatabase.Fields("SQLpath")
Response.Write rstDatabase.Fields("entry")
Preview = Imagepath
Else
Response.Write "Record not found"
End If
Else
Response.Write "Invalid input"
End If
End Function
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 2</title>
</head>
<body>
<img
src = ".<%= strSomePic %>"
width = "575"
height = "425"
/>
<br>
<form action="new_page_2.asp?bSave=True" method="post">
Enter index information:
<input type="text" name="Cindex"><br><br>
<input type="submit" value="Submit">
</form>
<p>
</body>
</html>