Hello,
my problen must be simple but i have not find a way to solve it.
I am using IIS and mysql and i have a database which i retrieve data with the ASP. The problem is that i can not insert data to the database.
The code is simple, i have 3 text boxes and a submit button. The database has 3 fields (name,surname,telephone) I want to enter in the textboxes the data and then to be inserted in the database.
The problem is that i can not insert the variables. If i try to enter
strQuery = "Insert into clientid (name,surname,telephone) Values ('john','mathews','1234')" works fine but i am not sure i know the syntax for entering variables is strQuery = "Insert into clientid (name,surname,telephone) Values ('"a"','"b"','"c"')"? Sorry for the silly question but i have stucked here for 2 days and i can not find an answer.
What is the correct syntax for entering the variables a,b,c (blue color) to the sql query (red color)?
Thank you
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form action="insert_into.asp" method="post" name="form1" target="_blank">
<p>Name:
<input type="text" value = "<%=a%>" name="textfield1">
</p>
<p>Surname:
<input type="text" name="textfield2">
</p>
<p>Telephone:
<input type="text" name="textfield3">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
</body>
</html>
<%
a=request.form ("textfield1")
b=request.form ("textfield2")
c=request.form ("textfield3")
dim conn, sqltext
dim rs
dim counter
dim strquery
set conn = Server.CreateObject("ADODB.Connection")
set rs = Server.CreateObject("ADODB.Recordset")
conn.Open "DSN=hotel"
rs.ActiveConnection = conn
response.write "<h2>Fields In The 'Contacts' Table:</h2>"
rs.Open "Select * From clientid"
while not rs.EOF
response.write rs.fields(0).value & " "
response.write rs.fields(1).value & " "
response.write rs.fields(2).value & "<br>"
rs.MoveNext
wend
strQuery = "Insert into clientid (name,surname,telephone) Values ('"a"','"b"','"c"')"
conn.Execute strQuery
rs.close
%>
ps: the error that i get is Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/insert_into.asp, line 75, column 68
strQuery = "Insert into clientid (name,surname,telephone) Values ('"a"','"b"','"c"')"