[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1531
  • Last Modified:

ASP sql insert

Im trying to submit data into an SQL database.

It works but two values show up with no value

Here is my statement

objRS.Open "Insert into reqtbl (Mname, cmpsub, codeline, bldlabel, Nullcis) Values ('" & strMName & "','" & strcmpname & "','" & stros & "','" & strbuild & "','"& strcis & "')",objConnection,3,3

The "Mname" does not show up and the "cis"

mname comes from

 if not(request.form("MName")="" or IsNull(request.form("MName"))) then
   Session("UserName") = request.form("MName")

and

cis comes from

do while not objRS.EOF
                    if objRS("cis") = strBuild then
                         strSelected = " Checked "
                    else
                         strSelected = ""
                    end if
%>
<tr><td>
      <td width="700" style="word-wrap:break-word;"><input type=checkbox name=cis value="<%=objRS("cis")%>"style="font-size:8px;"></td>
<td><%=objRS("cis")%></td>

then I do a

dim strcis, strMName

strcis = Request.Form("cis")
strMName = Request.Form("MName")



0
tmurray22
Asked:
tmurray22
1 Solution
 
CubeRootCommented:
Have you tried printing strcis & strMName just before objRS.Open to see if they have a value?
0
 
ThinkPaperCommented:
do a response.write on your values at the beginning of your code and see if it's actually passing. I tend to put a "!!" at the end so I know that it actually printed out if it comes out blank.

response.write Request.Form("MName") & "!!MNAme"
response.write Request.Form("cis")  & "!!CIS!"
0
 
John_LennonCommented:
i see you give the value to cis in a checkBox, but i don't see where you give the value to MName, you also have a checkBox for this value?
0
 
houguanCommented:
<input type=checkbox name=cis value="<%=objRS("cis")%>"style="font-size:8px;"></td>

I think your code here put wrong value?

should replace the value with strSelected
<input type=checkbox name=cis value="<%=strSelected%>"style="font-size:8px;"></td>

Besides,

Try to change this
"if objRS("cis") = strBuild then"

to

IF strComp(objRS("cis")),strBuild)=0 THEN

to do a string comparison if it is your case.

For the MNAme,

With your code,
if not(request.form("MName")="" or IsNull(request.form("MName"))) then
   Session("UserName") = request.form("MName")

strMName = Request.Form("MName")  <-- this one should change to Session("UserName")

and become

strMName = Session("UserName")

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now