Hi all.
I got an error for my SQL syntax.
The error lies in the commented line shows below.
<%
nokpA = request.Form("kp1")&request.Form("kp2")&request.Form("kp3")
set ic = server.CreateObject("adodb.recordset")
ic.open "select * from staf where nokp = nokpA" ,conn 'error is here
if not ic.eof then %>
<script>
alert("Maaf, no KP telah wujud");
</script>
<%end if%>
The error tells that:
No value given for one or more required parameters.
I think there must be something wrong with the SQL syntax but I couldnt figure out whts wrong with that line.
So, I need help from you all to explain to me.
Thanks in advance.
candelbc
04-26-2006, 12:49 AM
Try changing the line to:
ic.open "select * from staf where nokp = " & nokpA ,conn
Terrorke
04-26-2006, 02:01 AM
Have you set a connectionstring variable?
In your case the variable conn
azrina
04-26-2006, 02:41 AM
Yes, I have set the connection string variable.
I also have changed the line but I got another prob,SQL syntax error in INSERT INTO statement.
I haVe checked the statement and I think theres no error with that.
Can anyone here help me to detect the error?
Thanks in advance.
<%
nokpA = request.Form("kp1")&request.Form("kp2")&request.Form("kp3")
set ic = server.CreateObject("adodb.recordset")
ic.open "select * from staf where nokp = '"&nokpA&"'" ,conn 'error is here
if not ic.eof then %>
<script>
alert("Maaf, no KP telah wujud");
</script>
<%
end if
set idata = server.CreateObject("adodb.recordset")
idata.open "insert into staf (bno,nama,nokp,alamat1,bandar,negeri,poskod,tel1,emel,status,kad_dhl,kad_skr,trk_lantik,jawatan_id,b ahagian_id) values("&request.Form("bno")&",'"&request.Form("nama")&"','"&nokpA&"','"&request.Form("alamat")&"','"&request.Form("bandar")&"',"&request.Form("negeri")&",'"&request.Form("tel1")&"','"&request.Form("emel")&"','"&request.Form("status")&"',1,1,#"&tlantik&"#,"&request.Form("jwtn")&","&request.Form("bhgn")&")" ,conn
%>
candelbc
04-26-2006, 08:54 AM
I tend to use EXECUTE when executing INSERT, UPDATE, and DELETE. You might save yourself some troubles and use spaces on your string concatenation..
Execute Statement example:
SQLstring = "insert into staf (bno,nama,nokp,alamat1,bandar,negeri,poskod,tel1,emel,status,kad_dhl,kad_skr,trk_lantik,jawatan_id,b ahagian_id) values("&request.Form("bno")&",'"&request.Form("nama")&"','"&nokpA&"','"&request.Form("alamat")&"','"&request.Form("bandar")&"',"&request.Form("negeri")&",'"&request.Form("tel1")&"','"&request.Form("emel")&"','"&request.Form("status")&"',1,1,#"&tlantik&"#,"&request.Form("jwtn")&","&request.Form("bhgn")&")"
conn.Execute SQLstring
Maybe an improved way of setting up your SQL string:
Bear in mind, this is just how I choose to write them to make coding easier and code reading easier yet. Everyone has their own personal coding style. This just happens to be mine. I think it tends to make it easier when you must go back and alter something.
Do you have the permission to insert into your db?
azrina
04-27-2006, 12:11 AM
Thank you for all the replies.
When I do testing with the text field one by one, I have found that data type that is set to number cannot be left unfilled. So, that is why I keep getting the same error that is error syntax INSERT INTO statement. I didnt know that number data type is so sensitive.
I am new in programming and this teaches me alot.
Anyway, thanks for all the replies. I really appreciate.
webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved.