Querying A Random Record From A Table on MSSQL
For years i have used SELECT .. ORDER BY RAND() on MySQL.. For hours i have been looking for a sample query on the web for getting a random record from a table on MSSQL.. From my search i found that for getting a random record from a table all you have to do is…
SELECT * FROM Tablename ORDER BY NEWID();
I dont know what exactly is that NEWID() thing on order by.. But from my search for documentations i found the following link helpfull
http://mkruger.cfwebtools.com/index.cfm/2005/9/29/mssql.random.row (i know its cfm but the SQL info is still good)
Im still trying to get more info on what NEWID() is… If you guys know what NEWID() does drop me a comment..
CakePHP Framework
I got a bit of time today to do some research on the web.. for months now i have been hearing about the Ruby on Rails.. and how easy it is to develop robust web apps using that.. i spent a lot of time reading and downloading stuff on rubyonrails.org. Sadly though i have no time to learn another programming language… but the screencast on the site is very interesting..
And since a PHP guy i tried looking for a framework that is patterned after Ruby on Rails, that way i dont have to learn a new programming language just to get something up.. Also i needed something that runs on PHP 4.. and most of what i find are for PHP 5.. it had me thinking for a bit that i need to upgrade the server to PHP 5 but sadly i cant just do that cause some sites hosted on it requires PHP 4.
After a couple of hours of searching i found a very nice framework that runs on PHP 4.. its cakePHP. From the info on their site seems a very nice and promising framework.. I will be posting my experience on having the thing running. Im planning to have it running on my window 2003 test server and IIS.. So Stay Tuned…
Last Insert ID on MSSQL and ASP
I have been looking around on the web for how do i get the last insert id from MSSQL and ASP.. It is kinda easy on PHP and MYSQL, just use mysql_insert_id right? That is not the case on ASP.. it is kinda easy though.. I found the code below on the web cant remember where though…
The trick is to add “SELECT @@identity;” to the insert query. Say you have a table named “users” with a fields named user_id, user_lastname, and user_firstname. The user_id is set to autoincrement.. so the insert query for it would then be
INSERT INTO users(user_lastname, user_firstname) VALUES (“Dela Cruz”, “Juan”);
Just add the query mentioned after the ;(semi-colon) so that the resulting query would then be
INSERT INTO users(user_lastname, user_firstname) VALUES (“Dela Cruz”, “Juan”);SELECT @@identity;
And on ASP.. asumming that your connection is conn
SQLstr = “INSERT INTO users(user_lastname, user_firstname) VALUES (‘Dela Cruz’, ‘Juan’);SELECT @@identity;”
set rs = conn.Execute(strSQL).nextRecordSet
newid = rs(0)
newid will then contain the autoincremented user_id for the recently inserted record…
ASP Documentation
After days of frustating search for ASP Documentation on MSDN.. Maybe i just dont know where to find stuff on MSDN.. Right now im thinking MS has made that thing very confusing.. i dont know why that is.. maybe there is just too much information in there that you can kinda get lost when browsing through it.
Since i cant seem to find anything on MSDN.. i search around the web and i found this site that i think would help much especially for people still trying to learn ASP.. The site is http://www.w3schools.com/asp. I find the documentation kinda user friendly just ignore the ads on the bottom… those thing right after the next and previous links on the button.. kinda hard at first where the ASP stuff ends and where the ads begin… but once you read through it you kinda get use to it..
File Uploader Class for VB
I finally found a free Upload Class for ASP.. I was excited on finally taking another step towards the completion of the ASP web application im working on… i hear myself “finally”.. Im going to use the class so i can upload an image to a directory on the server… i have to forget about auto resizing and thumbnailing which i usually add as a freebie on my PHP work… i did some research on the image resizing thing but i think it is going to be complicated and the odds of me finding a free code out there on the web to use is close to none.. i will have to settle for just uploading the image nothing fancy for now..
The Upload class is on an ASP script you can just include on your scripts… kinda convenient at this point… You can find the script here http://www.asp101.com/articles/jacob/scriptupload.asp. The page also includes and very easy to understand instructions on how to get the thing working.. At this point i take my statements before of how hard it is to do uploads on ASP.. the FileUploader class seems to work ok.. on the development server that is..
Sadly when i uploaded my script to the live server.. it was giving me an Internal Server Error.. I think it is due to the incorrect permissions so i requested the guys who runs the server to add IUSR_MACHINE name to the uploads folder sadly though i have to wait 24 hours for the requested permissions change to be take place.. no CHMOD on windows… Im glad to hear from a friend that that might be changing soon.. I certainly hope he is right cause it kinda a hassle to wait for the permissions to change.. its such a waste…
Remember VB?
For about 4 years now i have been working with most PHP.. last week i was given a task to try and add more stuff/functionality to an existing ASP site.. i gladly took it since i have been once a VB programmer and i figure this would be a good thing for me so i can start and learn ASP.. So right then i looked at the code of the site and first thing i tried to figure out was what type of database was being used.. Thanks to the previous developers the connection string was declared on global.asa… and from that i found that it uses MSSQL and off to the next problem… How do i manage that database?? Hmmmm… I cant use the tools i use to manage MySQL databases like SQLYog and PHPMyAdmin.. So first i try and search for some tools on the web.. sadly everything was for sale… urggggg…. i hate commercial software.. After a couple of hours of fruitless search.. I tried asking my ASP developer friends.. and i found out that i would need to install the sql server client tools.. I proceeded in doing that… Now im using the Interprise Manager to manage the dbs and the sql analyzer to test queries and edit stored procedures.. Now i can work..
Until i hit a point that i need to do some uploads… i can only wish there is some sort of $_FILES on ASP much like what is on PHP… Makes our lives kinda easier… but sadly there is none.. all the script i found on the web uses some sort of thirdparty thing which is commercial and i would need to shell out more cash.. Upon knowing that it is like this for ASP.. it made me thankfull to the PHP developers for making our lives a lot easier… or maybe its just be… cause im just starting on ASP.. maybe i would be better at this in time..
Up until now im still looking for free stuff for handling uploads on ASP… If any of you guys know of any just leave me a comment.. One thing i notice though is that when i tried and searching for samples and articles on ASP.. i always get unrelated stuff… plus i just dont know where to find the documentation on functions and objects on ASP.. i know it somewhere on MSDN.. And dont you just hate the dead links from the articles on ASP.. if you guy also know of a one stop documentation on ASP.. let me know.. : )
