 |
| Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

December 1st, 2004, 10:47 AM
|
|
Authorized User
|
|
Join Date: Nov 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks Chris.
I will try it out, but I didnt use longtext in my database. I used more of varchar.
is this going to affect the code in anyway?
cheers.
|
|

December 1st, 2004, 10:59 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
|
|
The error I mentioned is ( AFAIK) only with longtext field types, not varchar.
Which line does the error occur on?
How are the tables in your query related? You may need to re-write the query using joins.
Cheers,
Chris
|
|

December 1st, 2004, 11:52 AM
|
|
Authorized User
|
|
Join Date: Nov 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Chris,
Currently I havent linked any of the tables in my database.
This is the code I'm working on right now.
Help me out.
cheers.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {font-weight: bold}
-->
</style>
</head>
<body>
<%
Dim DB
Set DB = Server.CreateObject ("ADODB.Connection")
DB.Open "driver={MySQL ODBC 3.51 Driver};server=localhost;uid=root;pwd=;database=as setdb"
Dim RS
Set RS = Server.CreateObject ("ADODB.Recordset")
RS.Open "SELECT * FROM asset, branch, location, type, cost", DB
%>
<%
If RS.EOF And RS.BOF Then
Response.Write "There are 0 records."
End If
%>
</p>
<form action="modify_asset.htm" method="get" name="modify" id="modify" >
<table width="" border="1" cellspacing="2" cellpadding="2">
<tr>
<th scope="col"><span class="style1">Asset Number</a> </span></th>
<th scope="col"><span class="style1">Location </a></span></th>
<th scope="col"><span class="style1">Description</a> </span></th>
<th scope="col"><span class="style1">Branch</span></th>
<th scope="col"><span class="style1">Type</span></th>
<th scope="col"><span class="style1">Category</span></th>
<th scope="col"><span class="style1">Cost Center</span></th>
<th scope="col"><span class="style1">Serial Number</span></th>
<th scope="col"><span class="style1">Model</span></th>
<th scope="col"><span class="style1">Purchase Date</span></th>
<th scope="col"><span class="style1">Quantity</span></th>
<th scope="col"><span class="style1">Tax Value</span></th>
<th scope="col"><span class="style1">Insured Value</span></th>
<th scope="col"><span class="style1">Scrap Value</span></th>
</tr>
<tr>
<%
While Not RS.EOF 'makes sure that you don't continue looping past the End of the File
Dim asset_number
If VarType(RS.Fields("asset_number")) = vbObject Then
asset_number = ""
Else
asset_number = RS.Fields("asset_number").Value
End If
Response.Write("<td width=100><center>" & GetLongTextValue(RS.Fields ("asset_description")) & "<center>" & "</td>")
Dim location_name
If VarType(RS.Fields("location_name")) = vbObject Then
'location_name = ""
Else
location_name = RS.Fields("location_name").Value
End If
Response.Write("<td width=100><center>" & location_name & "<center>" & "</td>")
Dim asset_description
If VarType(RS.Fields("asset_description")) = vbObject Then
asset_description = ""
Else
asset_description = RS.Fields("asset_description").Value
End If
Response.Write("<td width=100><center>" & asset_description & "<center>" & "</td>")
Dim branch_name
If VarType(RS.Fields("branch_name")) = vbObject Then
branch_name = ""
Else
branch_name = RS.Fields("branch_name").Value
End If
Response.Write("<td width=100><center>" & branch_name & "<center>" & "</td>")
Dim type_name
If VarType(RS.Fields("type_name")) = vbObject Then
type_name = ""
Else
type_name = RS.Fields("type_name").Value
End If
Response.Write("<td width=100><center>" & type_name & "<center>" & "</td>")
Dim asset_category
If VarType(RS.Fields("asset_category")) = vbObject Then
asset_category = ""
Else
asset_category = RS.Fields("asset_category").Value
End If
Response.Write("<td width=100><center>" & asset_category & "<center>" & "</td>")
Dim cost_bearer
If VarType(RS.Fields("cost_bearer")) = vbObject Then
cost_bearer = ""
Else
cost_bearer = RS.Fields("cost_bearer").Value
End If
Response.Write("<td width=100><center>" & cost_bearer & "<center>" & "</td>")
Dim asset_serial
If VarType(RS.Fields("asset_serial")) = vbObject Then
asset_serial = ""
Else
asset_serial = RS.Fields("asset_serial").Value
End If
Response.Write("<td width=100><center>" & asset_serial & "<center>" & "</td>")
Dim asset_model
If VarType(RS.Fields("asset_model")) = vbObject Then
asset_model = ""
Else
asset_model = RS.Fields("asset_model").Value
End If
Response.Write("<td width=100><center>" & asset_model & "<center>" & "</td>")
Dim asset_purchase_date
If VarType(RS.Fields("asset_purchase_date")) = vbObject Then
asset_purchase_date = ""
Else
asset_purchase_date = RS.Fields("asset_purchase_date").Value
End If
Response.Write("<td width=100><center>" & asset_purchase_date & "<center>" & "</td>")
Dim quantity
If VarType(RS.Fields("quantity")) = vbObject Then
quantity = ""
Else
quantity = RS.Fields("quantity").Value
End If
Response.Write("<td width=100><center>" & quantity & "<center>" & "</td>")
Dim purchase_price
If VarType(RS.Fields("purchase_price")) = vbObject Then
purchase_price = ""
Else
purchase_price = RS.Fields("purchase_price").Value
End If
Response.Write("<td width=100><center>" & purchase_price & "<center>" & "</td>")
Dim asset_tax_value
If VarType(RS.Fields("asset_tax_value")) = vbObject Then
asset_tax_value = ""
Else
asset_tax_value = RS.Fields("asset_tax_value").Value
End If
Response.Write("<td width=100><center>" & asset_tax_value & "<center>" & "</td>")
Dim asset_insured_value
If VarType(RS.Fields("asset_insured_value")) = vbObject Then
asset_insured_value = ""
Else
asset_insured_value = RS.Fields("asset_insured_value").Value
End If
Response.Write("<td width=100><center>" & asset_insured_value & "<center>" & "</td>")
Dim asset_scrap_value
If VarType(RS.Fields("asset_scrap_value")) = vbObject Then
asset_scrap_value = ""
Else
asset_scrap_value = RS.Fields("asset_scrap_value").Value
End If
Response.Write("<td width=100><center>" & asset_scrap_value & "<center>" & "</td>")
RS.MoveNext 'Move to the next record in the results. Don't forget this!!!
WEnd
Response.Write("</table>")
RS.Close
DB.close 'Remember to close everything down
Function GetlongTextValue(pField)
Dim temp: temp = ""
If VarType(pField) <> vbObject Then
temp = pField.Value
End If
GetVaeCharValue = temp
End Function
%>
</table>
<p> </p>
<p> </p>
</form>
</body>
</html>
|
|

December 2nd, 2004, 02:21 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hi don baroo,
You haven't mentioned about which line throws that error? Posting the the line number which throws this error and the code of that line would be helpful to understand what you are missing.
Cheers!
_________________________
- Vijay G
Strive for Perfection
|
|

December 2nd, 2004, 04:53 AM
|
|
Authorized User
|
|
Join Date: Nov 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi happy,
Strangely enough it doesnt show the line causing the error. This makes me more confused. I'm a beginner too.
Here is the error:
Error Type:
Response object, ASP 0104 (0x80070057)
Operation not Allowed
/modify_asset.asp
Any ideas?
thanks for the reply.
cheers
|
|

December 2nd, 2004, 09:33 AM
|
|
Authorized User
|
|
Join Date: Nov 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Chris,
I've been able to solve the problem. I dont know what happened. I changed the length of the fields in my database and did a few other things and it worked. here is the final code.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Modify Asset</title>
<style type="text/css">
<!--
.style1 {font-weight: bold}
-->
</style>
</head>
<body>
<%
Dim DB
Set DB = Server.CreateObject ("ADODB.Connection")
DB.Mode = adModeReadWrite
DB.Open "driver={MySQL ODBC 3.51 Driver};server=localhost;uid=root;pwd=;database=as setdb"
Dim RS
Set RS = Server.CreateObject ("ADODB.Recordset")
RS.Open "SELECT * FROM asset, branch, location, type, cost LIMIT 10", DB
%>
<%
If RS.EOF And RS.BOF Then
Response.Write "There are 0 records."
End If
%>
</p>
<form action="modify_asset.htm" method="get" name="modify" id="modify" >
<table width="" border="1" cellspacing="2" cellpadding="2">
<tr>
<th scope="col"><span class="style1">Asset Number</a> </span></th>
<th scope="col"><span class="style1">Location </a></span></th>
<th scope="col"><span class="style1">Description</a> </span></th>
<th scope="col"><span class="style1">Branch</span></th>
<th scope="col"><span class="style1">Type</span></th>
<th scope="col"><span class="style1">Category</span></th>
<th scope="col"><span class="style1">Cost Center</span></th>
<th scope="col"><span class="style1">Serial Number</span></th>
<th scope="col"><span class="style1">Model</span></th>
<th scope="col"><span class="style1">Purchase Date</span></th>
<th scope="col"><span class="style1">Quantity</span></th>
<th scope="col"><span class="style1">Purchase Price</span></th>
<th scope="col"><span class="style1">Tax Value</span></th>
<th scope="col"><span class="style1">Insured Value</span></th>
<th scope="col"><span class="style1">Scrap Value</span></th>
</tr>
<tr>
<%
While Not RS.EOF 'makes sure that you don't continue looping past the End of the File
Response.Write("<td width=100><center>" & RS.Fields("asset_number") & "<center>" & "</td>")
Response.Write("<td width=100><center>" & RS.Fields("location_name") & "<center>" & "</td>")
Response.Write("<td width=100><center>" & RS.Fields("asset_description") & "<center>" & "</td>")
Response.Write("<td width=100><center>" & RS.Fields("branch_name") & "<center>" & "</td>")
Response.Write("<td width=100><center>" & RS.Fields("type_name") & "<center>" & "</td>")
Response.Write("<td width=100><center>" & RS.Fields("asset_category") & "<center>" & "</td>")
Response.Write("<td width=100><center>" & RS.Fields("cost_bearer") & "<center>" & "</td>")
Response.Write("<td width=100><center>" & RS.Fields("asset_serial") & "<center>" & "</td>")
Response.Write("<td width=100><center>" & RS.Fields("asset_model") & "<center>" & "</td>")
Response.Write("<td width=100><center>" & RS.Fields("asset_purchase_date") & "<center>" & "</td>")
Response.Write("<td width=100><center>" & RS.Fields("quantity") & "<center>" & "</td>")
Response.Write("<td width=100><center>" & RS.Fields("purchase_price") & "<center>" & "</td>")
Response.Write("<td width=100><center>" & RS.Fields("asset_tax_value") & "<center>" & "</td>")
Response.Write("<td width=100><center>" & RS.Fields("asset_insured_value") & "<center>" & "</td>")
Response.Write("<td width=100><center>" & RS.Fields("asset_scrap_value") & "<center>" & "</td>")
%>
</tr>
<%
RS.MoveNext 'Move to the next record in the results. Don't forget this!!!
WEnd
Response.Write("</table>")
RS.Close
DB.close 'Remember to close everything down
%>
</table>
<p> </p>
<p> </p>
</form>
</body>
</html>
I want to retrieve these data into textfields on a form. what is the best way to go about this.
thanks.
|
|

December 2nd, 2004, 09:44 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hi Don,
Glad it's working now.
I think you need to change this part of the code
Code:
<tr>
<%
While Not RS.EOF
To
Code:
<%
While Not RS.EOF
Response.Write "<tr>"
Otherwise you are closing but not opening a row for each record.
To write the values into text fields you could just do something like
Code:
<input type="text" name="YourFieldName" value="<%=Server.HTMLEncode(rs("YourFieldName").Value)%>" />
HTH,
Chris
|
|

December 2nd, 2004, 11:26 AM
|
|
Authorized User
|
|
Join Date: Nov 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Chris,
I'm still having the same error anytime I dont add LIMIT xx to the sql select statement.
Any ideas why this is so?
thanks for the reply.
cheers
|
|

December 2nd, 2004, 12:06 PM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hi Don,
Looks like one of the records in your recordset is causing the error.
Hard to tell why without seeing your database content / structure.
How big would a zip of the database folder (under mysql/data) be?
Cheers,
Chris
|
|

December 6th, 2004, 04:47 AM
|
|
Authorized User
|
|
Join Date: Nov 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Chris,
A zip of my database folder is 5kb. I zipped with WINRAR. I dont have your email address.
How do I send it to you?
Merry Christmas.
cheers.
|
|
 |