Author |
Topic |
CooLGiL
Junior Member
126 Posts |
Posted - 23 April 2002 : 08:40:22
|
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
|
what data type are the time and date fields ?
|
|
|
CooLGiL
Junior Member
126 Posts |
Posted - 23 April 2002 : 10:03:43
|
every thing is text.
|
|
|
Gremlin
General Help Moderator
New Zealand
7528 Posts |
|
CooLGiL
Junior Member
126 Posts |
Posted - 23 April 2002 : 10:09:15
|
i will try
|
|
|
CooLGiL
Junior Member
126 Posts |
Posted - 23 April 2002 : 10:12:08
|
thanks man you the best! it really helped me.
|
|
|
CooLGiL
Junior Member
126 Posts |
Posted - 23 April 2002 : 10:14:35
|
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!
|
|
|
Gremlin
General Help Moderator
New Zealand
7528 Posts |
Posted - 23 April 2002 : 10:22:14
|
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 |
|
|
CooLGiL
Junior Member
126 Posts |
Posted - 23 April 2002 : 10:23:35
|
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
|
|
|
CooLGiL
Junior Member
126 Posts |
Posted - 23 April 2002 : 10:27:15
|
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?
|
|
|
Gremlin
General Help Moderator
New Zealand
7528 Posts |
Posted - 23 April 2002 : 10:30:29
|
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 |
|
|
CooLGiL
Junior Member
126 Posts |
Posted - 23 April 2002 : 10:34:47
|
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 %>
|
|
|
Gremlin
General Help Moderator
New Zealand
7528 Posts |
Posted - 23 April 2002 : 10:47:02
|
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 |
|
|
CooLGiL
Junior Member
126 Posts |
Posted - 23 April 2002 : 10:54:14
|
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
|
|
|
CooLGiL
Junior Member
126 Posts |
Posted - 23 April 2002 : 10:58:29
|
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 |
|
|
Gremlin
General Help Moderator
New Zealand
7528 Posts |
Posted - 23 April 2002 : 10:59:46
|
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 |
|
|
Topic |
|