Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grab Bag 'O questions- Connections, Photos and more

Status
Not open for further replies.

joeisbatman

Programmer
Oct 8, 2001
39
US
QUESTION ONE:
Please bear with me- Lots of questions. This post is an old one that got lost in the forums, so I'm gonna repost it, hopefully Paul reads this ;-)

I'll sum up this problem: I want to close a connection after creating a recordset, using the client curosr location in an attempt to lessen the connections to my database. When I close the connection i get an error that everyone has told me means a field name doesn't match up with one in a database. I checked all the field names they are fine-- read on:

When I delete the "connectionToDatabase.close
set connectionToDatabase = nothing
at the top, it works. My code WAS after pauls suggestion:

frmID=Request.QueryString("ID")
Set connectionToDatabase=Server.CreateObject("ADODB.Connection")
connectionToDatabase.ConnectionTimeout=60
connectionToDatabase.Open "DSN=MyBuddyInfo1"
Set recordSet=Server.CreateObject("ADODB.RecordSet")

recordSet.cursorLocation = 2 'adUseClient
recordSet.cursorType = 3 'adOpenStatic
recordSet.lockType = 3 'adLockOptimistic

recordSet.Open "SELECT * FROM Users_Accounts_A WHERE ID=" &frmID, connectionToDatabase

connectionToDatabase.close
set connectionToDatabase = nothing%>
<html>
<body bgcolor=&quot;<% Response.Write(RecordSet(&quot;BGCOLOR&quot;)) %>&quot;
One of my friends thought that when we close the connection so early, the recordset object gets destroyed, which means it cannot find &quot;BGCOLOR&quot; in a recordset that is not there. Maybe I misunderstood the faq by paul about closing the connection so early...

QUESTION TWO i have a field where people can enter URLS. Sometimes people enter http:// and sometimes they just do www. I'm at a loss of finding a good way to parse the string to check if it starts with and if it doesn't add it. That way when its outputted to an html page the link actually works.

QUESTION THREE/FOUR
I want to store pictures. Users will upload the pics, and I will display then on a website. What is the best way to do this-- Should I store them in an access database or on the hard drive. I'm using win2k adv server, and I SUSPECT that somehow I can cache the database into ram, and hence give me faster results than reading binary data from the HD. Question four is-- if storing it into the DB is best, HOW on earth do I do such a thing, I know how to set up the datatype in access- just not how to actually GET the objects Data INTO the db.

QUESTION FIVE
Users may upload BMP's which take up WAY too much space, is there some kinda utility, or code i can use to auto convert the bmp's to jpegs and then store the jpeg? if there is some type of code that does it could you be very specific, I am still learning asp/VBscript.
 
Here is some code I use in an ASP page that retrieves a URL from a database. I made it based on what had been entered as a web link into the database. The entries were not always the same, so my code makes them all the same, with http:// on the beginning.

<%
' Set up the hyperlink data...
ws=rs.Fields.Item(&quot;Website&quot;).Value
If Trim(ws) <> &quot;&quot; Then ' If there is web site info
' Do away with any beginning and ending Parenthesis
If left(ws,1) = &quot;(&quot; Then
ws=Mid(ws,2)
End If
If Mid(ws, len(ws), len(ws)) = &quot;)&quot; Then
ws=Mid(ws, 1, len(ws)-1)
End If
' If the info doesn't contain &quot; then add it to the beginning
If (Left(ws, 4) <> &quot;http&quot;) and (Left(ws, 3) <> &quot;ftp&quot;) and (Left(ws, 4) <> &quot;nntp&quot;) Then
ws = &quot; + ws
End If
%>
<td class=&quot;normal><a href=&quot;<%=ws%>&quot; target=&quot;_blank&quot;><%=(rs.Fields.Item(&quot;Conference_Name&quot;).Value)%></a>
<%
Else %>
<td class=&quot;normal&quot; ><%=Replace(rs.Fields.Item(&quot;Conference_Name&quot;).Value, Chr(13), &quot;, &quot;)%>
<%
End If %>
 
I suppose you might want to add this https:// option also...

If (Left(ws, 4) <> &quot;http&quot;) and (Left(ws, 5) <> &quot;https&quot;) and (Left(ws, 3) <> &quot;ftp&quot;) and (Left(ws, 4) <> &quot;nntp&quot;) Then
...

 
You should place all the returns from the db in an array, using arrResults = RecordSet.getrows before you close the connection.
That way you free up the ressources on the server, but still keep the data to do phun stuph with ;) later on in the code...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top