473,387 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

A little bit of help needed

132 100+
Hello guys,

I'm a real newbie so sorry that I may ask stupid questions but I'm stuck:

Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim con,sql_update,name,form_id,data_source
  3. form_id = CInt(Request.Form("id"))
  4. data_source =  "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _ Server.MapPath("employees.mdb")
  5.  
  6.  
  7. name = "Select Name From users where id = " & form_id 
  8.  
  9. If _
  10.  name == "John" _ 
  11. Then _
  12.    sql_update = "Update users Set status = 'True' where id = " & form_id _
  13. Else _
  14.    sql_update = "Update users Set status = 'False' where id = " & form_id _
  15. End If
  16.  
  17.  
  18.  
  19.  Set con = Server.CreateObject("ADODB.Connection")
  20.  con.Open data_source
  21.  con.Execute sql_update
  22.  con.Close
  23.  Set con = Nothing
  24. Response.Redirect "showall.asp" 
  25.  
  26. %>
  27.  
I've been deducting this from other code and I was quite proud of myself for writing this what to my opinion should work. But unfortunately it doesn't :-)
I get the "Page cannot be displayed"-page.

If anyone could help me to clarify for me what I'm doing wrong here, that would be very nice.

Greets,
Cainnech
Dec 23 '08 #1
6 1743
CroCrew
564 Expert 512MB
Line 24: Response.Redirect "showall.asp"

Seems the logical starting place to look. Do you have a page called “showall.asp” sitting in the same folder as the one that you post the code from?

Regards,
CroCrew~
Dec 23 '08 #2
Cainnech
132 100+
Yes it does.

And that code works since I already use it on another page where I can delete records.
Dec 23 '08 #3
jhardman
3,406 Expert 2GB
if name == "John" ... in asp you do not use double = signs, just one. Also, the line continuation marks are unnecessary, and incorrect if you are using an "end if" statement:
Expand|Select|Wrap|Line Numbers
  1. If name = "John" Then
  2.    sql_update = "Update users Set status = 'True' where id = " & form_id
  3. Else
  4.    sql_update = "Update users Set status = 'False' where id = " & form_id
  5. End If
Make sure your friendly error messages are off, then sometimes you need to force the actual error message to show up (instead of the "page can not be displayed" message). One fast way to force the asp error message to show up is to substitute the text of the page with a simple "hello world" message that couldn't possibly contain an error. After you see the correct page, put the code back and hit refresh, this should show the asp error message.

Let me know if this helps.

Jared
Dec 24 '08 #4
Cainnech
132 100+
@jhardman
This did the trick.

I'll probably run into syntax-translation errors a lot more since I'm only used to program in Javascript.

But thanks a lot Jared!
Dec 25 '08 #5
Cainnech
132 100+
I thought my problem was solved but not completely.

Although it now changes the value to false even if my statement is true.
I've looked into it and it seems that the value for "name" is completely off.

Expand|Select|Wrap|Line Numbers
  1. name = "Select Name From users where id = " & form_id  
  2.  
  3. If name = "John"  Then  
  4.    sql_update = "Update users Set status = 'True' where id = " & form_id  
  5.  
this is what it says now.
Unfortunately, the value of name now is : Select Name From users where id = 8

Now I didn't open my database yet so he won't do it correctly s he has nowhere to look so I have to open my database and perform a sql lookup first.

My problem now is that I don't know how to lookup a value in a database using SQL and store it into a variable.

So basically what I want to do is;
- lookup a value at a specified place in the database and store it in a variable (name in this case)
- compare it to a predefined variable (John in this case)
- update a different cell within the same id (status in this case)

Help would be appreciated.
Dec 26 '08 #6
jhardman
3,406 Expert 2GB
when you say
Expand|Select|Wrap|Line Numbers
  1. name = "SELECT ..."
you are just assigning a string variable. What you want is to execute a sql command and store the result in the variable. Does this make sense? Your original code shows how to execute a sql command (one of the last lines in the original code you posted). Unfortunately, I can't remember ever trying to look up a single value from a db using classic ASP. It seems like it should go something like this:
Expand|Select|Wrap|Line Numbers
  1. name = con.execute ("SELECT ...")
Let me know if this works, otherwise I might be able to suggest something else.

Jared
Jan 2 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Tongu? Yumruk | last post by:
I have a little proposal about type checking in python. I'll be glad if you read and comment on it. Sorry for my bad english (I'm not a native English speaker) A Little Stricter Typing in Python...
7
by: rkrueger | last post by:
Given the following 3 Tables: CREATE TABLE ( NOT NULL , NOT NULL CONSTRAINT DEFAULT (getdate()), NULL , CONSTRAINT PRIMARY KEY CLUSTERED (
5
by: iminal | last post by:
I am trying to make a very simple program and am very new to the whole programming thing. my program is supposed to ask a user for any time in the for format XX:XX:XX and then ask for a time...
10
by: Tom Dacon | last post by:
I'm curious to see if anyone has an opinion on this little design question - I'm doing a computational astronomy library in C#, purely for my own use, and one of the things that happens regularly...
2
by: MichaelH | last post by:
Hi all, I am writing a program that has to draw musical notes on a staff. To do this I need to draw Ellispses (representing the notes) on a horizontal line and rotate them slightly (by 15...
3
by: Dan Trowbridge | last post by:
Hi everyone, In my attempt to port code from VS 6.0 to VS.NET I had some code break along the way, mostly due to not adhereing closely to the C++ standard. This may be another instance but I...
10
by: Flare | last post by:
Hi I just read and experimented with normal .net GUI apps and deployed them with notouch deployment strategie as smartclients. Is it just me, or i this an very neglected topic? For me it...
16
by: Durumdara | last post by:
Hi ! I have a problem. I have a little tool that can get data about filesystems and wrote it in python. The main user asked me a GUI for this software. This user is needed a portable...
11
by: iTISTIC | last post by:
Developing a new app and am trying to make this my first truly OOP/3-Tier app. I understand the principles of the presentation, business, and data layers. I do, however, have some questions on...
4
by: toton | last post by:
I have a code like this typedef unsigned int uint; class PtuInfo{ bool increasing_; uint ptIndex_; uint begin_; uint end_; public: PtuInfo(uint begin,uint end,bool back): increasing_(!back),
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.