Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 help nedded in sql+asp... its very important D:
 New Topic  Topic Locked
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 3

CooLGiL
Junior Member

126 Posts

Posted - 23 April 2002 :  08:40:22  Show Profile  Send CooLGiL an ICQ Message
Yo All, im making a project and ihave aliitle problem look at my code:

<%
dim ttitle, bbody, wwriter, ddate, ttime

set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("News.mdb")
Conn.Errors.Clear

conn.Execute "INSERT INTO news (body, title, writer, time, date) VALUES ('gil went to the marker' , 'the gil' , 'binder' , '12:22:00' , '23/10/02')"
conn.close
set conn=nothing
%>


help nedded :) the problem is:

Microsoft JET Database Engine error '80040e14'

Syntax error in INSERT INTO statement.

/News/add.asp, line 8


please help


Edited by - coolgil on 23 April 2002 08:42:43

Edited by - coolgil on 23 April 2002 08:44:21

Edited by - coolgil on 23 April 2002 08:45:21

Edited by - coolgil on 23 April 2002 08:48:55

Edited by - coolgil on 23 April 2002 08:53:02

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 23 April 2002 :  09:29:55  Show Profile  Visit HuwR's Homepage
what data type are the time and date fields ?

Go to Top of Page

CooLGiL
Junior Member

126 Posts

Posted - 23 April 2002 :  10:03:43  Show Profile  Send CooLGiL an ICQ Message
every thing is text.

Go to Top of Page

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 23 April 2002 :  10:08:00  Show Profile  Visit Gremlin's Homepage
Might want to change your column names Date and Time also as they are both reserved words.

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q209187

www.daoc-halo.com
Go to Top of Page

CooLGiL
Junior Member

126 Posts

Posted - 23 April 2002 :  10:09:15  Show Profile  Send CooLGiL an ICQ Message
i will try

Go to Top of Page

CooLGiL
Junior Member

126 Posts

Posted - 23 April 2002 :  10:12:08  Show Profile  Send CooLGiL an ICQ Message
thanks man you the best!
it really helped me.

Go to Top of Page

CooLGiL
Junior Member

126 Posts

Posted - 23 April 2002 :  10:14:35  Show Profile  Send CooLGiL an ICQ Message
now ihave two other problems:

1. how can i make that when ppl will write lets say in textbox [*img]link[/img] it will really be a link?

2. how can i do that when i insert a line the line will be the first in the table?

tahnks all!

Go to Top of Page

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 23 April 2002 :  10:22:14  Show Profile  Visit Gremlin's Homepage
Have a look in inc_functions.asp and see how snitz does it, I think the specific function in there is called ReplaceURLs (to do [URL] type links) and for Images I think its ReplaceImageTags

When you insert a line (row) into a table its never really going to appear at the top. What you need to do is when you select the items from the database use an ORDER BY clause to get them in the order you want them.

For instance, If I wanted to retrieve the items in your database sorted by Date then I would do something like this

SELECT Body, Title, Writer, Time, Date FROM news ORDER BY Date DESC

The ORDER BY Date DESC tells the database to give the results to me in Descending Date order

Hope that helps a little.

www.daoc-halo.com
Go to Top of Page

CooLGiL
Junior Member

126 Posts

Posted - 23 April 2002 :  10:23:35  Show Profile  Send CooLGiL an ICQ Message
in problem 2 look here:


do while not rs("ID") = news_number_page
response.write "<div align.............>"
rs.MoveNext
loop



i want the news ordering from the newest to the oldest.
its not doing it automatic becuse ID type is auto number.
and news_number_page=5

Go to Top of Page

CooLGiL
Junior Member

126 Posts

Posted - 23 April 2002 :  10:27:15  Show Profile  Send CooLGiL an ICQ Message
quote:

Have a look in inc_functions.asp and see how snitz does it, I think the specific function in there is called ReplaceURLs (to do [URL] type links) and for Images I think its ReplaceImageTags

When you insert a line (row) into a table its never really going to appear at the top. What you need to do is when you select the items from the database use an ORDER BY clause to get them in the order you want them.

For instance, If I wanted to retrieve the items in your database sorted by Date then I would do something like this

SELECT Body, Title, Writer, Time, Date FROM news ORDER BY Date DESC

The ORDER BY Date DESC tells the database to give the results to me in Descending Date order

Hope that helps a little.

www.daoc-halo.com



man, thanks.
but i want that the loop will set to start from the EOF to the BOF got My Idea?

Go to Top of Page

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 23 April 2002 :  10:30:29  Show Profile  Visit Gremlin's Homepage
Then you'll need to and an ID Field to each record that increments by 1 each time a new record is added.

In Access its called an "AutoNumber" type field. You would then use this field in your ORDER BY clause.

www.daoc-halo.com
Go to Top of Page

CooLGiL
Junior Member

126 Posts

Posted - 23 April 2002 :  10:34:47  Show Profile  Send CooLGiL an ICQ Message
already did that look:

<%
dim news_number_page, table_border_color, table_bgcolor, text_body_color ,text_writer_color, text_date_color, text_time_color, text_body_font, text_body_size, text_head_font, text_head_size, text_head_color, title_align, body_align, writer_align, time_align, date_align, table_align

set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("News.mdb")

Conn.Errors.Clear

set rs = Server.CreateObject("ADODB.Recordset")

Sql = "select * from design"
set rs = Conn.Execute (Sql)
table_border_color=rs("table_border_color")
table_bgcolor=rs("table_bgcolor")
text_body_color=rs("text_body_color")
text_date_color=rs("text_date_color")
text_time_color=rs("text_time_color")
text_body_font=rs("text_body_font")
text_body_size=rs("text_body_size")
text_head_font=rs("text_head_font")
text_head_size=rs("text_head_size")
text_head_color=rs("text_head_color")
news_number_page = rs("news_number_page")
title_align=rs("title_align")
body_align=rs("body_align")
time_align=rs("time_align")
date_align=rs("date_align")
writer_align=rs("writer_align")
table_align=rs("table_align")
rs.close
set rs=nothing
conn.close
set conn=nothing

set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("News.mdb")

Conn.Errors.Clear

set rs = Server.CreateObject("ADODB.Recordset")

Sql = "SELECT * FROM news ORDER BY ID"
set rs = Conn.Execute (Sql)

do while not rs("ID") = news_number_page
response.write "<div align...>"
rs.MoveNext
loop

rs.close
set rs=nothing
conn.close
set conn=nothing
%>




Go to Top of Page

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 23 April 2002 :  10:47:02  Show Profile  Visit Gremlin's Homepage
So your Halfway there then.

What relationship has your News_Number_Page to your ID though ? that looks a little weird. To simply print out your Data in ID Order you would do something like this


sSQL = "SELECT * FROM news ORDER BY ID"
set rs = conn.execute(sSQL)
while not rs.EOF
for each item in rs.fields
Response.Write item.value & "<BR>"
next
rs.MoveNext()
wend
rs.Close()
set rs = nothing





www.daoc-halo.com
Go to Top of Page

CooLGiL
Junior Member

126 Posts

Posted - 23 April 2002 :  10:54:14  Show Profile  Send CooLGiL an ICQ Message
sorry man, i can urdenstand your point.
my code i working good but i want that the ID Will Be Opsidedown like this:
6
5
4
3
2
1
and not like the normal (ASC)
1
2
3
4
5
6
but when im trying to change the ASC TO DESC its doing a white page with nathing on it:



set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("News.mdb")

Conn.Errors.Clear

set rs = Server.CreateObject("ADODB.Recordset")

Sql = "SELECT * FROM news ORDER BY ID DESC"
set rs = Conn.Execute (Sql)


do while not rs("ID") = news_number_page
response.write "<div al...>"
rs.MoveNext
loop

rs.close
set rs=nothing
conn.close
set conn=nothing


Go to Top of Page

CooLGiL
Junior Member

126 Posts

Posted - 23 April 2002 :  10:58:29  Show Profile  Send CooLGiL an ICQ Message
quote:

So your Halfway there then.

What relationship has your News_Number_Page to your ID though ? that looks a little weird. To simply print out your Data in ID Order you would do something like this


sSQL = "SELECT * FROM news ORDER BY ID"
set rs = conn.execute(sSQL)
while not rs.EOF
for each item in rs.fields
Response.Write item.value & "<BR>"
next
rs.MoveNext()
wend
rs.Close()
set rs = nothing






www.daoc-halo.com



and its not eorking its doing the same as the old one do...


Edited by - coolgil on 23 April 2002 10:59:21
Go to Top of Page

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 23 April 2002 :  10:59:46  Show Profile  Visit Gremlin's Homepage
Changing the order from ASC to DESC shouldnt make any difference, so your code is not 'working good' you must have something else wrong.

That code I pointed out early as not looking right is probably where, around the do while not rs("ID") = news_number_page

What is the value stored in News_Number_Page ??

rs("ID") changes everytime you do an rs.MoveNext() will it ever match News_Number_Page ? thats whats probably causing a loop

maybe try using do while not rs.EOF as your loop condition instead.



www.daoc-halo.com


Edited by - Gremlin on 23 April 2002 11:07:32
Go to Top of Page
Page: of 3 Previous Topic Topic Next Topic  
Next Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.36 seconds. Powered By: Snitz Forums 2000 Version 3.4.07