View Full Version : Learning ASP, I have a question.
Web Gazelle
Nov 10th 2005, 4:54 pm
I am trying to use an ASP script to change a database yes/no value from no to yes. It is probably simple, but I can't seem to get it to work. Can anyone give me an idea of how to do this? :confused:
iShopHQ
Nov 10th 2005, 5:36 pm
what type of field is it? what types of database? what query are you using to attempt the update?
Web Gazelle
Nov 10th 2005, 6:19 pm
Databse is Access, it is a field in a table in the access database that has a yes/no data type. my query starts like this "update Customers set DeleteCode =..." Customers is the Table and DeleteCode is the table field.
Web Gazelle
Nov 10th 2005, 7:21 pm
Here is my line of code that has a problem.
var mySQL = "update Customers set DeleteCode = 'Yes' where Number = '" + Request.Form("Number") + "'";
What is wrong with it? I keep getting this error.
Data type mismatch in criteria expression.
Anyone shed some light here?
vectorgraphx
Nov 11th 2005, 6:16 am
try:
var mySQL = "update Customers set DeleteCode = 'True' where Number = '" + Request.Form("Number") + "'";
Web Gazelle
Nov 11th 2005, 7:32 am
I will give that a try, thanks.
jpcesar
Nov 11th 2005, 7:37 am
hey are you doing that in VBScript?
if so then replace the + with &
var mySQL = "update Customers set DeleteCode = 'Yes' where Number = '" & Request.Form("Number") & "'";
If Number is integer you don't need the ' ' around request.Form("Number")
Web Gazelle
Nov 11th 2005, 7:39 am
Number is an integer but I am using javascript.
iShopHQ
Nov 11th 2005, 1:57 pm
the yes/no field in access is actually a bit, not the word yes or no.
in access it is either false (no) or true(yes)
If Number is an actual data type of NUMBER, not a TEXT or MEMO then you don't need the two sets of quotes. If it isn't, you do.
to set to yes:
var mySQL = "update Customers set DeleteCode = TRUE where Number = " & Request.Form("Number")
to set to no
var mySQL = "update Customers set DeleteCode = FALSE where Number = " & Request.Form("Number")
Web Gazelle
Nov 14th 2005, 8:22 am
Cool, thanks for the help. The book I am using didn't explain that too well.
iShopHQ
Nov 14th 2005, 4:56 pm
Hope it works...
If you're anal, like I am, and like everything to balance out, you can still put quotes on the end by putting two next to each other:
var mySQL = "update Customers set DeleteCode = FALSE where Number = " & Request.Form("Number") &""
Web Gazelle
Nov 15th 2005, 5:05 pm
I got it to finally work with this code...
var mySQL = "update Customers set DeleteCode = TRUE where Number = " + Request.Form("Number")
Thanks for the help everyone. I guess I need to get a better book. :rolleyes:
jimrthy
Dec 8th 2005, 5:43 pm
Hope it works...
If you're anal, like I am, and like everything to balance out, you can still put quotes on the end by putting two next to each other:
var mySQL = "update Customers set DeleteCode = FALSE where Number = " & Request.Form("Number") &""
I don't get it at all. What's the point to the last pair of double quotes? You said it had something to do with balance, but it balanced out quite a ways before.
This may sound like I'm being sarcastic. I'm 100% not. I'm just trying to understand what you're doing.
Regards,
James
jimrthy
Dec 8th 2005, 5:47 pm
Thanks for the help everyone. I guess I need to get a better book.
Unless computer books are really cheap wherever you're living, that's probably not the way to go.
You need to write more code. (So do I, for that matter).
It sounds to me as though books have taken you about as far as you're going to go. It's time to spread your wings, hop out of the nest, and start doing something with your code.
That's just my impression, of course. And I'll be the first to admit that I'm most likely wrong.
vectorgraphx
Dec 9th 2005, 5:56 am
I don't get it at all. What's the point to the last pair of double quotes? You said it had something to do with balance, but it balanced out quite a ways before.
Don't let me answer for ishopHQ, he may mean something different, but what i feel like he means here is basically, while yes, the (& "") is redundant and unnecessary, it is nonetheless logical, i.e. the sql statement starts and ends with quotes, and you escape/reenter your sql statement in pairs. on a simple sql statement like this one it really seems entirely unnecessary, as anyone who works with sql knows you don't need the trailing & "". however, if you have a VERY complex sql statements with lots of nested inner joins, order by clauses, renamed variables, etc... and it's not working right, being sure that all ampersands, apostrophes, #'s, quotes, etc.... are accounted for in pairs can be useful in troubleshooting errors. But you're right, it's not needed at all, especially in something like this - however alot of programmers will go ahead and put it in as a matter of principle.
Unless computer books are really cheap wherever you're living, that's probably not the way to go.
You need to write more code. (So do I, for that matter).
too true. I need to write more as well... and i've been writing ASP code every day for over 3 years. Books will only take you so far - real world application and daily usage is the only way to go. TOTAL IMMERSION, BABY! lol :D
VG
Web Gazelle
Dec 9th 2005, 12:21 pm
I believe in hands-on learning 100%. This was just to get my feet wet. :D
vectorgraphx
Dec 9th 2005, 12:43 pm
I believe in hands-on learning 100%. This was just to get my feet wet.
wouldn't you be getting your HANDS wet then? hehe
badum-pum-clash!
jimrthy
Dec 9th 2005, 7:07 pm
Don't let me answer for ishopHQ, he may mean something different, but what i feel like he means here is basically, while yes, the (& "") is redundant and unnecessary, it is nonetheless logical, i.e. the sql statement starts and ends with quotes, and you escape/reenter your sql statement in pairs. on a simple sql statement like this one it really seems entirely unnecessary, as anyone who works with sql knows you don't need the trailing & "". however, if you have a VERY complex sql statements with lots of nested inner joins, order by clauses, renamed variables, etc... and it's not working right, being sure that all ampersands, apostrophes, #'s, quotes, etc.... are accounted for in pairs can be useful in troubleshooting errors. But you're right, it's not needed at all, especially in something like this - however alot of programmers will go ahead and put it in as a matter of principle.
Ok, that makes sense. Thanks. I haven't seen that technique before.
Then again, I haven't done much really complex SQL. (The only I've had a job that even got close, we had a DBA to write stored procedures for us. Cake).
Web Gazelle
Dec 12th 2005, 8:58 am
wouldn't you be getting your HANDS wet then? hehe
badum-pum-clash!
I guess I would... Since I like to just dive right in, I would be getting all wet. ;)
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.