Click to See Complete Forum and Search --> : How tosend datas using n loops to the table


hari
12-27-2002, 04:49 PM
Hello Friends,
I am getting problem in sending the user data filled in the html forms to my access database.

i.e., if the user types his name as

Hari Ba'bu
(datatype is text in field desgin)
and other field datas are given etc.,

then I am getting the following error

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression ''hari ba'bu',2,285,'aaa aaaa','','','','','bbb bbbb','bbb bbbbb','bbb bbbb','bbb4444',735,'12/28/02')'.

and if the user types his name without single quotes then the record is inserted properly.

So , give me the solution to insert the records along with single quote's

with regards
hari

Bullschmidt
01-08-2003, 03:31 PM
And just for reference here are a few articles about that:

How to Deal with Apostrophes in your SQL String - 5/18/1999
http://www.4guysfromrolla.com/webtech/051899-1.shtml
Just uses a Replace function.

Replacing Single Quotes when formatting SQL
http://www.aspfree.com/asp/startpage.asp?id=38
Just uses a Replace function.

Properly encoding a SQL statement by Robert Chartier nothingmn@netexecutive.com
http://www.aspfree.com/asp/startpage.asp?id=46
Just uses a Replace function.

HOWTO: Handle Quotes and Pipes in Concatenated SQL Literals
http://support.microsoft.com/support/kb/articles/q178/0/70.asp

hari
03-08-2003, 11:37 PM
Hello Developer,
I am collecting the personal details from my customer while he registers and storing it in the database. (he selected his country has india) from the list of countries ( i stored all the countries with unique code in a table) from their i am listing in the registration form.

but , When he needs to edit his profile i have to show the selected country when he registered as first and the remaining all in the list.How to do this?

I stored all the personal details of my customer along with unique code of india (eg . 5) in another table

regards
hari

Ribeyed
03-09-2003, 08:36 AM
hi,
sorry but i think your missing the "end if":




<option value="AL" <%If myRst.Fields("state") = "AL" Then Response.Write("selected")%>>Alabama</option>
<option value="AK" <%If myRst.Fields("state") = "AK" Then Response.Write("selected")%>>Alaska</option>
<option value="AB" <%If myRst.Fields("state") = "AB" Then Response.Write("selected")%>>Alberta</option>
cont.......






<option value="AL" <%If myRst.Fields("state") = "AL" Then Response.Write("selected") End If%>>Alabama</option>
<option value="AK" <%If myRst.Fields("state") = "AK" Then Response.Write("selected") End If%>>Alaska</option>
<option value="AB" <%If myRst.Fields("state") = "AB" Then Response.Write("selected") End If%>>Alberta</option>
cont........

hari
03-19-2003, 01:56 PM
Hello
This is a Time allotment system project using ASP.
I am listing up all the plants in select box along with departments,start time and end time to be assigned by the admin for the employees.
He may have n no of plants and he will assign the duty time for varoius plants for a day , by selecting the time as order.
How to send this datas to the table .
i.e assume if he allot duties for a employee


Worker Code selecting from theselect box ( Selecting the name) fetching the code from the value attribute.

Start time End Time Plant department (currently assume 3 plants in the company)

9 11 plant2 department3 (all are in the select box)

11 14 plant3 department2 (all are in the select box)

14 17 plant1 department1 (all are in the select box)


I have to insert these records i.e (3)tothe table , along with the admin employee code (whose assigning the job) the worker code (to whom assigned the job) with todays date when he submits the form
regards
hari

currently I finished it by assuming 3 plants in the company.
Following is the code :

******************************************
first page i am sending it by attachment empcategory.asp

second page after submission

<html>
<head>
<link rel="stylesheet" type="text/css" href="cssfiles/styles.css">
<style>
font.ffield { font-family : Arial,Helvetica ; font-size : 10pt ; color : #000000 ; font-weight : none ; text-decoration : none ; }
font.fcomment { font-family : Arial,Helvetica ; font-size : 8pt ; color : #000000 ; font-weight : none ; text-decoration : none ; }
font.ferror { font-family : Arial,Helvetica ; font-size : 10pt ; color : red ; font-weight : none ; text-decoration : none ; }
font.fheader { font-family : Arial,Helvetica ; font-size : 10pt ; color : #333366 ; font-weight : bold ; text-decoration : none ; }
th.th1 { border:1px solid #999999; background-image : url('../images/r8_tb_2.gif') ; background-repeat : repeat-x ; font-size:16px; font-family:Times New Roman, Arial,'MS Sans Serif'; font-weight:bold; color:"Blue" }
td.td4 { border-color : #999999 ;border-width : 1px ; border-style : solid ; font-size:20px; font-family:Times New Roman, Arial,'MS Sans Serif'; font-weight:bold; color:"Black"; }
</style>
</head>
<body BGCOLOR="#f5f5f5" bottomMargin="5" leftMargin="5" rightMargin="5" topMargin="5">
<div align="left" style="position:absolute;top:100">
<%

set con=server.createobject("adodb.connection")
con.cursorlocation=3

cnpath="DBQ=" & Server.mappath("../dBase/tallotdb.mdb")
con.open "DRIVER={Microsoft Access Driver (*.mdb)};"&cnpath

set rs1= Server.CreateObject("ADODB.Recordset")

rs1.Open "admins",con
compqry1="select * from admins"
Set rs1=con.execute(compqry1)
flag=0
if not rs1.bof <> rs1.eof then
rs1.movefirst
while not rs1.eof
if rs1("user")=Session("user") AND rs1("pwd")=Session("pwd") then
flag=1
end if
rs1.movenext
wend
end if
if flag=0 then
Response.write("This Page can be accessed only by the Authenticated Administrators")
Response.end
end if
rs1.close

assignerempcode=Request.QueryString(Session("empcode"))
'assignerdptcode=Request.QueryString(Session("deptcode"))
shiftallotempcode=Request.QueryString("selEmpCode")

Response.write("Assignercode" & Session("empcode") & "<br>Allotted Employee Code " & shiftallotempcode &"<br>")
' plant column by row

p11=Request.QueryString("11")
p21=Request.QueryString("21")
p31=Request.QueryString("31")
p41=Request.QueryString("41")
p12=Request.QueryString("12")
p22=Request.QueryString("22")
p32=Request.QueryString("32")
p42=Request.QueryString("42")
p13=Request.QueryString("13")
p23=Request.QueryString("23")
p33=Request.QueryString("33")
p43=Request.QueryString("43")
p14=Request.QueryString("14")
p24=Request.QueryString("24")
p34=Request.QueryString("34")
p44=Request.QueryString("44")

' first plant qry column by row plant1
qry1="insert into MTimeAllot(AssignerCode,EmpCode,PlantCode,DeptCode,STime,ETime,FDate,TDate,InTime,OutTime) values (" & Session("empcode") & "," & shiftallotempcode & "," & p11 & "," & p21 & "," & p31 & "," & p41 & ",'" & date() & "','" & date() &"','nil','nil')"
' second plant qry column by row plant2
qry2="insert into MTimeAllot(AssignerCode,EmpCode,PlantCode,DeptCode,STime,ETime,FDate,TDate,InTime,OutTime) values (" & Session("empcode") & "," & shiftallotempcode & "," & p12 & "," & p22 & "," & p32 & "," & p42 & ",'" & date() & "','" & date() &"','nil','nil')"
' third plant qry column by row plant3
qry3="insert into MTimeAllot(AssignerCode,EmpCode,PlantCode,DeptCode,STime,ETime,FDate,TDate,InTime,OutTime) values (" & Session("empcode") & "," & shiftallotempcode & "," & p13 & "," & p23 & "," & p33 & "," & p43 & ",'" & date() & "','" & date() &"','nil','nil')"

con.execute(qry1)
con.execute(qry2)
con.execute(qry3)

Response.write("<br><br> inserted the records")

Response.end

%>

hari
03-20-2003, 12:47 PM
Hello
This is a Time allotment system project using ASP.
I am listing up all the plants in select box along with departments,start time and end time to be assigned by the admin for the employees.
He may have n no of plants and he will assign the duty time for varoius plants for a day , by selecting the time as order.
How to send this datas to the table .
i.e assume if he allot duties for a employee


Worker Code selecting from theselect box ( Selecting the name) fetching the code from the value attribute.

Start time End Time Plant department (currently assume 3 plants in the company)

9 11 plant2 department3 (all are in the select box)

11 14 plant3 department2 (all are in the select box)

14 17 plant1 department1 (all are in the select box)


I have to insert these records i.e (3)tothe table , along with the admin employee code (whose assigning the job) the worker code (to whom assigned the job) with todays date when he submits the form
regards
hari

currently I finished it by assuming 3 plants in the company.
Following is the code :

******************************************
first page i am sending it by attachment empcategory.asp

second page after submission

<html>
<head>
<link rel="stylesheet" type="text/css" href="cssfiles/styles.css">
<style>
font.ffield { font-family : Arial,Helvetica ; font-size : 10pt ; color : #000000 ; font-weight : none ; text-decoration : none ; }
font.fcomment { font-family : Arial,Helvetica ; font-size : 8pt ; color : #000000 ; font-weight : none ; text-decoration : none ; }
font.ferror { font-family : Arial,Helvetica ; font-size : 10pt ; color : red ; font-weight : none ; text-decoration : none ; }
font.fheader { font-family : Arial,Helvetica ; font-size : 10pt ; color : #333366 ; font-weight : bold ; text-decoration : none ; }
th.th1 { border:1px solid #999999; background-image : url('../images/r8_tb_2.gif') ; background-repeat : repeat-x ; font-size:16px; font-family:Times New Roman, Arial,'MS Sans Serif'; font-weight:bold; color:"Blue" }
td.td4 { border-color : #999999 ;border-width : 1px ; border-style : solid ; font-size:20px; font-family:Times New Roman, Arial,'MS Sans Serif'; font-weight:bold; color:"Black"; }
</style>
</head>
<body BGCOLOR="#f5f5f5" bottomMargin="5" leftMargin="5" rightMargin="5" topMargin="5">
<div align="left" style="position:absolute;top:100">
<%

set con=server.createobject("adodb.connection")
con.cursorlocation=3

cnpath="DBQ=" & Server.mappath("../dBase/tallotdb.mdb")
con.open "DRIVER={Microsoft Access Driver (*.mdb)};"&cnpath

set rs1= Server.CreateObject("ADODB.Recordset")

rs1.Open "admins",con
compqry1="select * from admins"
Set rs1=con.execute(compqry1)
flag=0
if not rs1.bof <> rs1.eof then
rs1.movefirst
while not rs1.eof
if rs1("user")=Session("user") AND rs1("pwd")=Session("pwd") then
flag=1
end if
rs1.movenext
wend
end if
if flag=0 then
Response.write("This Page can be accessed only by the Authenticated Administrators")
Response.end
end if
rs1.close

assignerempcode=Request.QueryString(Session("empcode"))
'assignerdptcode=Request.QueryString(Session("deptcode"))
shiftallotempcode=Request.QueryString("selEmpCode")

Response.write("Assignercode" & Session("empcode") & "<br>Allotted Employee Code " & shiftallotempcode &"<br>")
' plant column by row

p11=Request.QueryString("11")
p21=Request.QueryString("21")
p31=Request.QueryString("31")
p41=Request.QueryString("41")
p12=Request.QueryString("12")
p22=Request.QueryString("22")
p32=Request.QueryString("32")
p42=Request.QueryString("42")
p13=Request.QueryString("13")
p23=Request.QueryString("23")
p33=Request.QueryString("33")
p43=Request.QueryString("43")
p14=Request.QueryString("14")
p24=Request.QueryString("24")
p34=Request.QueryString("34")
p44=Request.QueryString("44")

' first plant qry column by row plant1
qry1="insert into MTimeAllot(AssignerCode,EmpCode,PlantCode,DeptCode
,STime,ETime,FDate,TDate,InTime,OutTime) values (" & Session("empcode") & "," & shiftallotempcode & "," & p11 & "," & p21 & "," & p31 & "," & p41 & ",'" & date() & "','" & date() &"','nil','nil')"
' second plant qry column by row plant2
qry2="insert into MTimeAllot(AssignerCode,EmpCode,PlantCode,DeptCode
,STime,ETime,FDate,TDate,InTime,OutTime) values (" & Session("empcode") & "," & shiftallotempcode & "," & p12 & "," & p22 & "," & p32 & "," & p42 & ",'" & date() & "','" & date() &"','nil','nil')"
' third plant qry column by row plant3
qry3="insert into MTimeAllot(AssignerCode,EmpCode,PlantCode,DeptCode
,STime,ETime,FDate,TDate,InTime,OutTime) values (" & Session("empcode") & "," & shiftallotempcode & "," & p13 & "," & p23 & "," & p33 & "," & p43 & ",'" & date() & "','" & date() &"','nil','nil')"

con.execute(qry1)
con.execute(qry2)
con.execute(qry3)

Response.write("<br><br> inserted the records")

Response.end

%>


__________________
with regards
hari