Welcome, Guest ( Customer Panel | Login )




 All Forums
 VPCart Forum
 General help me questions
 asp/html help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

apswater
VP-CART Super User

444 Posts

Posted - March 09 2007 :  15:07:26  Show Profile  Visit apswater's Homepage  Reply with Quote
I have been working on this a bit...

What it is supposed to do it simple.

It is a basic form with a text area.

The problem I have is it only saves the first line of the textarea while the preview below works just fine... any hints? Simon buddy?

The database field is set to memo. I tried text, but same thing.


file is tech.asp

<table width="550" align="center">

<font face="arial">
<b>
Write a Technote
</b>
<td width=550 align=center bgcolor="lightblue">

<table width=500 bgcolor="lightblue">
<td bgcolor="lightblue" align="left">
<font face="arial" size="1">
<form ACTION="tech.asp" method="POST">
Title<br>
<INPUT TYPE="TEXT" NAME="TITLE" VALUE="<%=REQUEST.FORM("TITLE")%>" size="80"> <br>
<br>
Body<BR>
<TEXTAREA cols="60" rows="10" name="text1">
<%=request.form("text1")%>
</textarea>
<BR>
Keywords
<br>
<INPUT TYPE="TEXT" NAME="Keywords" VALUE="<%=REQUEST.FORM("keywords")%>" size="80"> <br>

<%


dim oConntn, mysqltn, iptn, titletn, texttn, keywordstn, datetn, timetn, recaffected4
iptn=Request.ServerVariables ("remote_addr")
titletn=Request.form("title")
texttn=Request.form("text1")
keywordstn=Request.form("keywords")
datetn=date()
timetn=time()


Set oConntn = Server.CreateObject("ADODB.Connection")
oConntn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\inetpub\database\technotes.mdb"

mysqltn="INSERT INTO technotes(datetn, timetn, titletn, keywordstn, iptn, texttn) VALUES('" & datetn & "','" & timetn & "','" & titletn & "','" & keywordstn & "','" & iptn & "','" & texttn & "')"




response.write "<font color=black size=1><B>" & mysqltn & "<br><br></b>"


oConntn.Execute mysqltn ,recaffected4

if err<>0 then
Response.Write("Error : ") & err & "<br><br>"
else
Response.Write("<h3>" & recaffected4 & " record added</h3>")
end if
oConntn.close


%>
<input type="submit" value="Post it">
</form>

<br>
Page Review
<br><br><pre><font size=2 face=arial>
<%=titletn%>
<br><br>
<%=texttn%>
</pre>
</td>
</table>

</td>
</table>

Edited by - apswater on March 09 2007 15:08:36

devshb
Senior Member

United Kingdom
1904 Posts

Posted - March 09 2007 :  15:57:21  Show Profile  Visit devshb's Homepage  Reply with Quote
it's possible that it is saving the newline, but it's saving it as a vbscript newline (vbcrlf) which you don't see in the raw data, instead of a <br> - if you want to display the output on a different page, replacing the physical newlines that you enter into the textfield as newlines on the webpage, then you'd need to do something like this:

mysqltn="INSERT INTO technotes(datetn, timetn, titletn, keywordstn, iptn, texttn) VALUES('" & datetn & "','" & timetn & "','" & titletn & "','" & keywordstn & "','" & iptn & "','" & replace(texttn,vbcrlf,"<br>") & "')"

it should also cater for single quotes, so ideally you'd actually want to do this:

Function TextToSQLVal(arg_in_val)
Dim tval
tval=arg_in_val
if (tval="" or IsNull(tval)=true) then
TextToSQLVal=""
exit function
end if
tval=Replace(tval,vbcrlf,"<br>")
tval=Replace(tval,"'","''")
TextToSQLVal=tval
End function


mysqltn="INSERT INTO technotes(datetn, timetn, titletn, keywordstn, iptn, texttn) VALUES('" & datetn & "','" & timetn & "','" & TextToSQLVal(titletn) & "','" & TextToSQLVal(keywordstn) & "','" & iptn & "','" & TextToSQLVal(texttn) & "')"

I can't remember exactly what character(s) are used when you do a newline from a textarea, but chr(10) is a newline feed, and chr(13) is a carriage return, so you might need to look at the raw data to see the ascii value and then work backwards when creating that function above. (vbcrlf is just a constant/definition of chr(13)&chr(10) I think, but I might be wrong)

Last time I did a function like that, I just used chr(10) because I think the chr(13) might be browser dependant as different browsers process textareas differently (ie try replacing vbcrlf in the above function with chr(10) if the function above doesn't work)


Simon Barnaby
Developer
[email protected]
www.BigYellowZone.com
Web Design, Online Marketing and VPASP addons

Edited by - devshb on March 09 2007 16:22:04
Go to Top of Page

apswater
VP-CART Super User

444 Posts

Posted - March 09 2007 :  16:56:44  Show Profile  Visit apswater's Homepage  Reply with Quote
interestingly complicated!

It doesnt grab any characters past the first line of input.

I have the preview read the variable and print it using <pre) to try and make it wysiwyg for my people who cant seem to be able to write a <br>, but that part is not important. It loads the full value of the textarea area and I verify this becasue the preview always prints out right. It is when it write to the database field that is cuts out anything after the first line. You would think a text area should be an easy thing! I hate asp bring back qbasic!

I guess I will have to take a look at how they do it for the category or products tables.... there has tyo be an easier way.

Anyone else?

(Thanks Simon)


Go to Top of Page

devshb
Senior Member

United Kingdom
1904 Posts

Posted - March 09 2007 :  17:33:34  Show Profile  Visit devshb's Homepage  Reply with Quote
try outputting the generated sql statement and see what it has in it; maybe you also have to trim out a chr(13) to make the sql statement valid.

vpasp doesn't use explicit insert statements; instead it just does a create-new cursor and then directly updates the cursor's fields; that's why it doesn't have all the same kind of text/character manipulation that a raw sql-statement generation would have (although it still does some manipulation to avoid hacker attacks etc)

Simon Barnaby
Developer
[email protected]
www.BigYellowZone.com
Web Design, Online Marketing and VPASP addons

Edited by - devshb on March 09 2007 17:39:29
Go to Top of Page

apswater
VP-CART Super User

444 Posts

Posted - March 09 2007 :  18:50:47  Show Profile  Visit apswater's Homepage  Reply with Quote
Yeah, you can see that is has a response.write mysqltn and it outputs all the characters.



all I am trying to do is input a quick article or q and A into a database and then on the other end, output them like vpasp does the
category's when the visitor wants to read them. I could do it with a message board, but I want to do it this way instead since we are the only ones going to be adding the text.

It should be so simple....


thanks





Edited by - apswater on March 23 2007 01:07:12
Go to Top of Page

apswater
VP-CART Super User

444 Posts

Posted - March 11 2007 :  15:28:30  Show Profile  Visit apswater's Homepage  Reply with Quote
Thanks Simon, it worked just fine. It converted the linefeeds to <br> which is just as good.

I guess if I do a replace in chr(32) or what ever space is to  , I should be able to keep all the spacing right?

thanks again.
Go to Top of Page

devshb
Senior Member

United Kingdom
1904 Posts

Posted - March 11 2007 :  16:42:32  Show Profile  Visit devshb's Homepage  Reply with Quote
you shouldn't need to do a replace for spaces, unless you specifically want to display, say, 2 consecutive spaces as 2 spaces, in which case you'd need to replace spaces with "[nbsp;"

(replacing the "[" in the above example with a "&" - I can't get that to display on the forum when using an &)

Simon Barnaby
Developer
[email protected]
www.BigYellowZone.com
Web Design, Online Marketing and VPASP addons

Edited by - devshb on March 11 2007 16:45:01
Go to Top of Page

apswater
VP-CART Super User

444 Posts

Posted - March 11 2007 :  17:02:36  Show Profile  Visit apswater's Homepage  Reply with Quote
Thanks,

You are a big help.

Yes, I want to keep the spacing. I want to make the text page as wysiwyg as I can so I can have a secretary type them in and be able to have attractive formatting.

Go to Top of Page

apswater
VP-CART Super User

444 Posts

Posted - March 22 2007 :  15:24:56  Show Profile  Visit apswater's Homepage  Reply with Quote
I am having trouble with ADODB Memo fields....

I can write the original text using plain text and converting it with replace as Simon suggested. The variable seems to hold more then 255 characters, but then I have more then 255 characters the database gets an error and I can no longer edit the field when I bring it back into my edit screen.

The online guide (w3.org) says there is a limit of 255 on the field name, but I cant find a limit on the field itself. Is there a special way i need to dimmension it?

When I repair the database I get a "could not find field 'description'"

I am not using any field called description, so I am not sure wht the eror really is. All I know is that it takes the text field which is a memo field and converts the many lines of text into '#############' and I lose it.

Any suggestions?
Go to Top of Page

devshb
Senior Member

United Kingdom
1904 Posts

Posted - March 23 2007 :  00:03:08  Show Profile  Visit devshb's Homepage  Reply with Quote
it might be the select statement that you're using to query-back the data; you can't use "group by" or "distinct" when querying memo fields (well, you can, but it will give misleading/confusing/wrong results as it only looks at the first 100 characters or so; not even 255 from what I can remember, only about 100 on access databases. so, if you select a distinct set of descriptions, you actually end up with duplicates if any of them have the first 100 characters or so which are the same).

so, avoid "group by", "distinct", and also if possible try to "order by" something smaller/different too.

you shouldn't need to re-dim it in the vbscript; a declared variable should be able to hold anything without redimming. the only exception to that is if you have multiple-dimensions (ie holding 50 different values in a single variable/array, like a poplist reference lookup)

Simon Barnaby
Developer
[email protected]
www.BigYellowZone.com
Web Design, Online Marketing and VPASP addons
Go to Top of Page

apswater
VP-CART Super User

444 Posts

Posted - March 23 2007 :  01:05:54  Show Profile  Visit apswater's Homepage  Reply with Quote
Thanks...

I can get it to work with

rsTn.Fields("TextTn") = left (texttn, 2048)

If I go bigger, I get a wierd database corruption.

I can initially stuff more characters into the texttn memo field (I am using access) and I can bring them into the edit form but one I go to update, I am limited to 2048. Any help would be appreciated.

What this does is a simple way of creating information pages that you can post your own advertising in. We klnow how search engines love info pages. Anyway, I am happy to share the code with you if you want to improve and release it.

this is my update code



<html>
<%


dim oConntn, rsTn, mysqltn, iptn, titletn, textTn, keywordstn, datetn, timetn

iptn=Request.ServerVariables ("remote_addr")
titletn=Request.form("TitleTs")
texttn=Request.form("TextTs")
texttn=replace(texttn, vbcrlf, "<br>")

idTs=Request.form("idTs")
keywordstn=Request.form("KeywordsTs")
HideTn=Request.form("HideTs")

datetn=date()
timetn=time()


Set oConntn = Server.CreateObject("ADODB.Connection")

Set rsTn = Server.CreateObject("ADODB.Recordset")

oConntn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=the database"

mysqltn = "select * FROM technotes where id=" & idTs

rsTn.Open mysqlTn, oconnTn, 1, 3

response.write rsTn.Fields("titleTn")

texttn=replace(texttn, vbcrlf, "<br>")

rsTn.Fields("TitleTn") = TitleTn

rsTn.Fields("TextTn") = left (texttn, 2048)
rsTn.Fields("hide") = hideTn

rsTn.Fields("KeywordsTn") = keywordsTn

on error resume next


rsTn.Update

rsTn.close

oConntn.close

etc.....
.

Edited by - apswater on March 23 2007 01:09:12
Go to Top of Page

devshb
Senior Member

United Kingdom
1904 Posts

Posted - March 23 2007 :  01:35:42  Show Profile  Visit devshb's Homepage  Reply with Quote
try using:

rsTn.open mysqlTn,oconnTn,adOpenKeyset,adLockOptimistic,adcmdText

instead of:

rsTn.Open mysqlTn, oconnTn, 1, 3

not sure if that'll fix it, but it might, as "1,3" would I think just be a readonly cursor so might not be allowing proper updates.

also, make sure you've got adovbs.inc (or shopvbs.asp) included in the file and/or its includes

and temporarily take out the "on error resume next" line so that you can spot any sql errors etc.

Simon Barnaby
Developer
[email protected]
www.BigYellowZone.com
Web Design, Online Marketing and VPASP addons

Edited by - devshb on March 23 2007 01:37:30
Go to Top of Page

apswater
VP-CART Super User

444 Posts

Posted - March 23 2007 :  10:59:35  Show Profile  Visit apswater's Homepage  Reply with Quote
Thanks, but that didnt quite work...

I get this error

Error Type:
ADODB.Recordset (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/techupdate.asp, line 33
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000
0 Item(s)
$0.00