|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
sql INSERT help: how to INSERT from a variable?
hello all... i was working with a .html file. But i can not enter value to my access database
from variable using SQL. Can you please tell me how to get the value in the variable 'nam' in dbcheck() method. i feel the problems are in the red lines highlighted below in my code. the .html code: <html> <head> <title>test jscript</title> <SCRIPT LANGUAGE="JavaScript" RUNAT="server"> <!-- function dbcheck() { ADOConn = new ActiveXObject("ADODB.Connection"); strConn = ""; strConn += "driver={Microsoft Access Driver (*.mdb)};"; strConn += "dbq=c:\\Inetpub\\wwwroot\\cctemp\\db2.mdb;"; ADOConn.Open(strConn); nam= document.req.textbox.value; sql="insert into tbl_name (name) values (' "&nam&" ')"; ADOConn.Execute(sql); } //--> </SCRIPT> </head> <body> <form name="req"> <p><input type=button value="add to db" onclick="dbcheck()"></p> <p><input type=text name="textbox"></p> </form> </body> </html> |
|
#2
|
||||
|
||||
|
doesn't javascript use the + as the concatenator?
so sql="insert into tbl_name (name) values (' "&nam&" ')"; becomes sql="insert into tbl_name (name) values ('" + nam + "')"; (you wounldn't want the spaces inside the SQL statement I don't think) It's a while since I used it javascript, and I never did (or knew you could do) a runat server veriant, I've strictly used it for events client side Sorry I couldn't help more -mwalts |
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > sql INSERT help: how to INSERT from a variable? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|