Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old September 19th, 2004, 01:25 AM
sh_joy sh_joy is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 10 sh_joy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy sql INSERT help: how to INSERT from a variable?

i have a .html file shown below. I just want to get the value from the variable
and insert that to by access database. 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>

Reply With Quote
  #2  
Old October 21st, 2004, 01:59 AM
Leslie's Avatar
Leslie Leslie is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Honolulu
Posts: 184 Leslie User rank is Corporal (100 - 500 Reputation Level)Leslie User rank is Corporal (100 - 500 Reputation Level)Leslie User rank is Corporal (100 - 500 Reputation Level)Leslie User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 20 h 29 m 2 sec
Reputation Power: 8
The semicolon does not belong OUTSIDE of the quotation, in fact you can delete it altogether. Secondly nam must contain a legal value (correct data type and length to fit into the table) and can only contain one value, not be an array of values.

You should provide the error message when posting so we know what your problem is.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > sql INSERT help: how to INSERT from a variable?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway