View Full Version : database connection
12-20-2004, 09:58 AM
I'm new to Java Script
I would need to connect to database (.mdb) and retrieve records from the database whenever any event triggered (checkbox/radio button)
Thus, I need to call a function (java script) whenever an event is triggered
however, I have no idea how can I connect to the database in the function.
Can somebody help me? I would really appreciate that
12-21-2004, 06:00 PM
i think you mean vbscript...using asp web pages.
here is a typical database mdb connection using asp to connect to a database:
Set getSet = Server.CreateObject("ADODB.Recordset")
myConnect.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath(database)
myText = "SELECT * FROM tableData"
hope it helps.
12-21-2004, 07:39 PM
Who is this..... (*Pause for effect)... Relaxzoolander?
Yochan, Mr. Zoolander is correct (as it's understood to be his custom) so I'm gonna slide this over to ASP.
12-22-2004, 06:50 AM
Thank you for the reply
what I meant was java script
I want to have a function (java script) and that function is used to connect to my database. Is that possible?
12-22-2004, 08:29 AM
Maybe look here http://www.tek-tips.com/viewthread.cfm?qid=963909 if it doesn't help maybe Google it.
Honestly I'd not seen JS used as such so it's a new one on me.
Stupid question, why java script?
12-22-2004, 10:36 AM
12-28-2004, 01:14 PM
You might be able to work something out by using a loop and the response buffer. I've never tried it, and it should work in theory, but I can't say I would actually recomend it.
The problem is that the db connection has to be handled on the server, somehow or another.
Some alternate ways to get the job done might be to make use of a frame or iframe, or depending on the specifics of what you need, you may be able to use Flash to get the info from the server.
Hope that helps..
12-29-2004, 07:02 AM
Thank you for all suggestions and advice. Those help me alot
Aight, I'm gonna work on it =)
12-30-2004, 01:13 AM
Here is how you can look at it:
VBScript = Server Side Script which runs on your computer and spits out what ever you want it to spit out to the client.
Even though I would not suggest doing that :) lol I have actually done it before but the application was used only by me so it was ok. If this is a public application then i suggest refreshing your page every time you need to connect to the db.
My 2 cents ;)
12-30-2004, 08:54 AM
thank you guys, you have been very helpfull
01-11-2005, 10:14 AM
I don't know if it is the best way, but one way would be to use images...
You can set up an asp page to send binary data and act like a 1x1 pixel clear image that can be called on using an html image tag.
When you want to send a variable back to the server, you can call that image from within your code, passing the variables through the querystring.
From there the asp puts the data into a db, or whatever you want the asp page to do.
The only tricky part is getting the asp page to send back info like it is a gif image, that way the little image can't be displayed thing doesn't show on the screen.
This handles info from client to server, but I don't know how you would go about it in the other direction.
Just from what you've mentioned here, it sounds like you should really look into flash actionscript. It's not a very searchengine friendly way to go, but it sounds liek you are doin something that doesn't need to be anyway.
Using flash, you can very easily send variables back and forth between the client and server. Depending on the type of app you are making, you can even open up a full-on socket connection between the two for even faster data transfer if speed is an issue (like building a chat application or online game). Of course for a socket connection, you will need to use something besides asp for the server, but for just sending and returning variables over http, asp would work fine.
01-14-2005, 04:43 PM
01-14-2005, 05:00 PM
[as was stated earlier]
so once a page is loaded...communication to asp is no longer active.
so...true 'live' communication does not really occur.
...this occurs at a new page call.
so...therefore...you can use a simple link to send variables to the asp page.
document.write("<a href='somepage.asp?col="+mycolor+"'>click here for the blue page.</a>")
[please note the use or single['] and double["] quotes.]
01-29-2005, 08:56 AM
vBulletin v3.0.3, Copyright ©2000-2013, Jelsoft Enterprises Ltd.