•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 361,950 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,598 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting
Views: 1010 | Replies: 3 | Solved
![]() |
•
•
Join Date: Mar 2007
Posts: 13
Reputation:
Rep Power: 2
Solved Threads: 0
Hi all, i need help on asp-sql code.
I have a form when I catch some infos and i want to create a new record into a database.
I have tried many syntax but I can't pass the variables a,b,c,d,e,f to sql string.
Please tell me how can i do it.
Thanks in advance, Roby.
I have a form when I catch some infos and i want to create a new record into a database.
I have tried many syntax but I can't pass the variables a,b,c,d,e,f to sql string.
Please tell me how can i do it.
asp Syntax (Toggle Plain Text)
<% a=Request.Form("LastName"); b=Request.Form("FirstName"); c=Request.Form("Street"); d=Request.Form("City"); e=Request.Form("Country"); f=Request.Form("Phone"); Response.write (a+" "+b+" "+c+" "+d+" "+e+" "+f); var sSQLString; sSQLString = "INSERT INTO tAuthors (LastName, FirstName, Street, City, Country, Phone) VALUES (a,b,c,d,e,f);" con.Execute(sSQLString); %>
Thanks in advance, Roby.
Last edited by peter_budo : Apr 4th, 2008 at 2:33 pm. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: Apr 2008
Posts: 20
Reputation:
Rep Power: 1
Solved Threads: 3
Ok, first I am going to assume that you have the code for the connection "con" somewhere else and this is just a snippet of what you have.
Secondly, why the 'var' and semicolon syntax? Are you writing this in JScript?
Your problem is that you are including a, b, c, d, e, f into a string literal. As such, they are letters, not variables. You need to concatenate them into the string.
Try this...(in VBScript)
Secondly, why the 'var' and semicolon syntax? Are you writing this in JScript?
Your problem is that you are including a, b, c, d, e, f into a string literal. As such, they are letters, not variables. You need to concatenate them into the string.
Try this...(in VBScript)
<%
Dim a, b, c, d, e, f
Dim sSQLString
a=Request.Form("LastName")
b=Request.Form("FirstName")
c=Request.Form("Street")
d=Request.Form("City")
e=Request.Form("Country")
f=Request.Form("Phone")
Response.write (a & " " & b & " " & c & " " & d & " " & e & " " & f)
sSQLString = "INSERT INTO tAuthors (LastName, FirstName, Street, City, Country, Phone) VALUES (" & a & ", " & b & ", " & c & ", " & d & ", " & e & ", " & f & ")"
con.Execute(sSQLString)
%>•
•
Join Date: Mar 2007
Posts: 13
Reputation:
Rep Power: 2
Solved Threads: 0
<% @LANGUAGE="JavaScript" %>
<!--#include file="adojavas.inc"-->
<%
var con;
var conString;
con = Server.CreateObject("ADODB.Connection");
conString = "Provider=Microsoft.Jet.OLEDB.4.0; "+ "Data Source= " + Server.MapPath("/public/booksDB.mdb");
con.Open(conString);
%>
<%
a=Request.Form("LastName");
b=Request.Form("FirstName");
c=Request.Form("Street");
d=Request.Form("City");
e=Request.Form("Country");
f=Request.Form("Phone");
Response.write (a+" "+b+" "+c+" "+d+" "+e+" "+f);
var sSQLString;
sSQLString = "INSERT INTO tAuthors (LastName, FirstName, Street, City, Country, Phone) VALUES (a,b,c,d,e,f);"
con.Execute(sSQLString);
%>
<%
con.Close( );
con = null;
%>This is my full code for this asp-javascript page.
The problem with the code you suggest me is that it isn't Javascript like and I need Javascript.
I really appreciate your help, but if you can help me with a javascript like code I thank you for ever
Last edited by roby4eldiablo : Apr 5th, 2008 at 3:30 am.
•
•
Join Date: Mar 2007
Posts: 13
Reputation:
Rep Power: 2
Solved Threads: 0
I have resolved the question.
With your code, a good vbscript to javascript translator and some adjustment it works fine.
this is the final code (the part that give problem before).
Thanks all.
With your code, a good vbscript to javascript translator and some adjustment it works fine.
this is the final code (the part that give problem before).
sSQLString = "INSERT INTO tAuthors (LastName, FirstName, Street, City, Country, Phone) VALUES ('" + a + "', '" + b + "','" + c + "', '" + d + "' , '" + e + "' , '" + f + "');"Thanks all.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb ASP Marketplace
- Shopping Cart Not Working (ASP.NET)
- PHP problem! (PHP)
- Very strange (PHP)
- JSTL compare string (JSP)
Other Threads in the ASP Forum
- Previous Thread: create dinamic dropdown box
- Next Thread: ASP Coding For Online System with SQL Server


Linear Mode