Avatar billede guzzie Nybegynder
26. februar 2001 - 11:53 Der er 32 kommentarer og
1 løsning

check box

hey there

I have a simple db that that show news on an asp page
however I am now trying to also incorperate a tru/false funchion so that only certain news items are published
I have now added a new colume to my database called publish and this is a true/false \"checkbox\"
Now I wish to on the asp page it self have a db connection only choose the news that are true
the connection looked like this before
SQLstmt = \"SELECT * FROM news ORDER BY dato;\"
now I have changed it to
SQLstmp = \"SELECT * FROM news where publish = False ORDER BY dato;\"
this is wrong as I found out, this is the first time I am working with a check box so Im a little stuck
Any help would be great
Guzzie
Avatar billede kasseper Nybegynder
26. februar 2001 - 11:56 #1
the checkbox returns 0 if unchecked and 1 if checked, that should be a very importent clue...:)
Avatar billede nute Nybegynder
26. februar 2001 - 11:58 #2
what is the value in your \'publish\' coloumn ? if it says true/false, assure that you spell it the same way ( with upper/lower case ), and try with \'\' around true or false..

/nute
Avatar billede kasseper Nybegynder
26. februar 2001 - 11:59 #3
nute >> det er er altså ikke nødvendigt......!
Avatar billede kasseper Nybegynder
26. februar 2001 - 11:59 #4
altså det med store/små bogstaver.
Avatar billede spectual Nybegynder
26. februar 2001 - 12:01 #5
Notice that javascript doesn\'t understand False - it has to be false (that goes for True too).

How is it wrong?
Avatar billede nute Nybegynder
26. februar 2001 - 12:01 #6
oki...
Avatar billede guzzie Nybegynder
26. februar 2001 - 12:05 #7
this is how the db connection looks now
<%
Set Conn = Server.CreateObject(\"ADODB.Connection\")
Conn.Open \"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\" & server.MapPath(\"media.mdb\")


SQLstmp = \"SELECT * FROM news where publish = \"true\" ORDER BY dato;\"
Set rs = conn.Execute(SQLstmt)

%>

this is the error I get
Microsoft VBScript compilation error \'800a0401\'

Expected end of statement

/mediascope/main_news.asp, line 15

SQLstmp = \"SELECT * FROM news where publish = \"true\" ORDER BY dato;\"

-->kasseper :) I tried the same using 1 instead of true but this didnt work either :(
Guzzie
Avatar billede nute Nybegynder
26. februar 2001 - 12:07 #8
Guzzie >> use single quotes instead of quotes around true

nute
Avatar billede guzzie Nybegynder
26. februar 2001 - 12:08 #9
k I tried that this is the error now
Microsoft OLE DB Provider for ODBC Drivers error \'80040e0c\'
Command text was not set for the command object.

/mediascope/main_news.asp, line 16

Guzzie :)
Avatar billede nute Nybegynder
26. februar 2001 - 12:09 #10
what does main_news.asp, line 16 read ?

/nute
Avatar billede guzzie Nybegynder
26. februar 2001 - 12:11 #11
could it be somthing like
SQLstmp = \"SELECT * FROM news where publish = value(\"1\") ORDER BY dato;\"
I know its wrong but you know what i mean I hope :)
guzzie
Avatar billede guzzie Nybegynder
26. februar 2001 - 12:11 #12
line 16 is
Set rs = conn.Execute(SQLstmt)
??? hmmmm
Guzzie
Avatar billede nute Nybegynder
26. februar 2001 - 12:13 #13
what type is the coloumn \'publish\' ? is it an number, String ? and you obviously put values into this coloumn...so you know if it contains 0/1, true/false, Y/N or something else ?!

/nute
Avatar billede guzzie Nybegynder
26. februar 2001 - 12:17 #14
ok I just checked my db again
the colume publish has a data type of Yes/No
hope it helps
Guzzie
Avatar billede nute Nybegynder
26. februar 2001 - 12:19 #15
Then your SQL should look like this

SQLstmp = \"SELECT * FROM news where publish = \'Yes\' ORDER BY dato;\"

/nute
Avatar billede guzzie Nybegynder
26. februar 2001 - 12:23 #16
hmmm I get this error now
Microsoft OLE DB Provider for ODBC Drivers error \'80040e0c\'
Command text was not set for the command object.

/mediascope/main_news.asp, line 16

Still line 16 error
here the db connection again
<%
Set Conn = Server.CreateObject(\"ADODB.Connection\")
Conn.Open \"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\" & server.MapPath(\"media.mdb\")


SQLstmp = \"SELECT * FROM news where publish = \'Yes\' ORDER BY dato;\"
Set rs = conn.Execute(SQLstmt) <--THIS IS LINE 16

%>
Guzzie
Avatar billede nute Nybegynder
26. februar 2001 - 12:25 #17
Try this

Set rs = Conn.Execute(SQLstmt)

as line 16

/nute
Avatar billede guzzie Nybegynder
26. februar 2001 - 12:37 #18
hmm sorry
same error ;(
Avatar billede nute Nybegynder
26. februar 2001 - 12:45 #19
strange...I must admit that it is some time since I worked with ASP...:-|

instead of Conn.execute, you could try to use

Set rs = server.createobject(\"ADODB.RecordSet\")
rs.Open SQLstmp, Conn, 3, 3

Otherwise, i\'m starting to run out of hints...

/nute
Avatar billede guzzie Nybegynder
26. februar 2001 - 14:10 #20
hey there again :)
nope sorry didnt help :(
Now I am thinking what if I just have a colume like publish and it was just a normal text colume where I my self have written yes or no
would it not be easier to do ??
Guzzie
Avatar billede nute Nybegynder
26. februar 2001 - 14:35 #21
I don\'t think its the SQL that causes a problem. You get the error \'Command text was not set for the command object.\' and this implies a problem with either the RecordSet or the Connection object. To check if the conection or recordset actually is working, just try with a simple sql:

e.g. SELECT * FROM news

if this goes wrong, there is something wrong with your recordset and/or connection

/nute
Avatar billede eagleeye Praktikant
26. februar 2001 - 15:02 #22
Have you tried this on:

SQLstmp = \"SELECT * FROM news where publish = \'True\' ORDER BY dato;\"
Avatar billede guzzie Nybegynder
26. februar 2001 - 15:16 #23
hey there eagleeye

nope sorry tried that and i still get the the same error on line 16
hmm sniff
Guzzie
Avatar billede eagleeye Praktikant
26. februar 2001 - 16:38 #24
Try this:

SQLstmp = \"SELECT * FROM news where publish = 1 ORDER BY dato;\"

0 = False
1 = True
Avatar billede nute Nybegynder
26. februar 2001 - 16:40 #25
Guzzie >> did you read my posting at 26/02 2001 14:35:07 ? I still don\'t think its the SQL that causes the problem...

/nute
Avatar billede guzzie Nybegynder
26. februar 2001 - 17:41 #26
-->nute

yes I did try that it did also work :)
But I expected this as I have used the db before
using a simple sql like you suggested

e.g. SELECT * FROM news

sniff ;(
Guzzie
Avatar billede nute Nybegynder
26. februar 2001 - 17:43 #27
is the database big ? can you send it to me and i\'ll take a look at it ?

/nute
Avatar billede eagleeye Praktikant
26. februar 2001 - 17:45 #28
Did you try this:

SQLstmp = \"SELECT * FROM news where publish = 1 ORDER BY dato;\"

0 = No
1 = Yes
Avatar billede guzzie Nybegynder
26. februar 2001 - 19:09 #29
eagleeye :)
yes I did and sorry it doesn´t ;(

nute/ no it doesnt its here if you want a look
http://www.guzzie.dk/help.zip

Guzzie
Avatar billede nute Nybegynder
26. februar 2001 - 19:24 #30
AAAAHHHHH !!!!! I think we both are blind :-|

in line 15 you call your SQL-string \'SQLstmp\', but in line 16 you call it \'SQLstmt\'... U c the diferrence ?? That should solve the problem, don\'t u think ??

/nute
Avatar billede nute Nybegynder
26. februar 2001 - 19:25 #31
and by the way, your first SQL was correct:

SELECT * FROM news where publish = True ORDER BY dato

/nute
Avatar billede guzzie Nybegynder
26. februar 2001 - 20:37 #32
nute thanks very much for your time
yep that was the problem :) hehe
pretty strange we didnt see it Blah :P
thank again
Guzzie
Avatar billede nute Nybegynder
27. februar 2001 - 09:44 #33
anytime guzzie :)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester