472,965 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,965 software developers and data experts.

need more help on split, replace and inserting into a databse

Hello again experts,

I have successfully pulled data from an LDAP server and now what I want
to do is drop the data into a database table. The following is my code
that will insert the data but that has problems.

Expand|Select|Wrap|Line Numbers
  1. FullName=Request.Form("Name")
  2. Email=Request.Form("Email")
  3. GivenName=Request.Form("GivenName")
  4. StreetAddress=Request.Form("StreetAddress")
  5.  
  6. FullNameDesc = Replace(FullName, "'", "''")
  7. EmailDesc = Replace(Email, "'", "''")
  8. GivenNameDesc = Replace(GivenName, "'", "''")
  9. StreetAddressDesc = Replace(StreetAddress, "'", "''")
  10.  
  11. strFullName = Split(FullNameDesc,", ")
  12. strEmailName = Split(EmailDesc,", ")
  13. strGivenName = Split(GivenNameDesc,", ")
  14. strStreetAddress = Split(StreetAddressDesc,", ")
  15.  
  16. Response.Buffer = True
  17. Set objConn = Server.CreateObject("ADODB.Connection")
  18. objConn.ConnectionString = (ConnectionInfoHidden)
  19. objConn.Open
  20.  
  21. For i = 0 to Ubound(strFullName)
  22. sSQL = "INSERT into Users (FullName, Email, GivenName,Address)"
  23. sSQL = sSQL & "VALUES ('" & strFullName(i) &"', '"& strEmailName(i)
  24. &"', '" & strGivenName(i) &"', '" & strStreetAddress(i) &"')"
  25. 'objConn.Execute sSQL
  26.  
  27. response.write sSql & "<BR>"
  28. Next
  29.  
  30.  
What is happening is for each user the fullname, email, given name and
address should get successfully entered into the database table however
some fullnames are getting the incorrect email address, given name etc.
while others are correct. Can anyone see a problem? I have checked the
data that is coming back from ldap and my code is definitely incorrect.
Why do some users get incorrect info...it's almost like they are
getting the prior users info.

Oct 26 '06 #1
9 2143
when you do a request.form there's no assurance that all fields collection will arrive in a relatively correct order.
You can verify this with a response.write stament follwing request.form for each field type. You will likely need to be more
explicit in naming form fields to create the desired association.

"MrHelpMe" <cl********@hotmail.comwrote in message news:11**********************@m7g2000cwm.googlegro ups.com...
Hello again experts,

I have successfully pulled data from an LDAP server and now what I want
to do is drop the data into a database table. The following is my code
that will insert the data but that has problems.

Expand|Select|Wrap|Line Numbers
  1. FullName=Request.Form("Name")
  2. Email=Request.Form("Email")
  3. GivenName=Request.Form("GivenName")
  4. StreetAddress=Request.Form("StreetAddress")
  5. FullNameDesc = Replace(FullName, "'", "''")
  6. EmailDesc = Replace(Email, "'", "''")
  7. GivenNameDesc = Replace(GivenName, "'", "''")
  8. StreetAddressDesc = Replace(StreetAddress, "'", "''")
  9. strFullName = Split(FullNameDesc,", ")
  10. strEmailName = Split(EmailDesc,", ")
  11. strGivenName = Split(GivenNameDesc,", ")
  12. strStreetAddress = Split(StreetAddressDesc,", ")
  13. Response.Buffer = True
  14. Set objConn = Server.CreateObject("ADODB.Connection")
  15. objConn.ConnectionString = (ConnectionInfoHidden)
  16. objConn.Open
  17. For i = 0 to Ubound(strFullName)
  18. sSQL = "INSERT into Users (FullName, Email, GivenName,Address)"
  19. sSQL = sSQL & "VALUES ('" & strFullName(i) &"', '"& strEmailName(i)
  20. &"', '" & strGivenName(i) &"', '" & strStreetAddress(i) &"')"
  21. 'objConn.Execute sSQL
  22. response.write sSql & "<BR>"
  23. Next
  24.  

What is happening is for each user the fullname, email, given name and
address should get successfully entered into the database table however
some fullnames are getting the incorrect email address, given name etc.
while others are correct. Can anyone see a problem? I have checked the
data that is coming back from ldap and my code is definitely incorrect.
Why do some users get incorrect info...it's almost like they are
getting the prior users info.

Oct 27 '06 #2
Jon,

Thanks for the reply. Is there any way you could show me this by
example? I'm still trying to learn asp and not sure what you mean by
"need to be more explicit in naming form fields". Does this require a
restructuring of my code? I was hoping to implement minimal changes to
my code. Could you possibly show me by using my exisiting code?
Thanks Jon.
Jon Paal wrote:
when you do a request.form there's no assurance that all fields collection will arrive in a relatively correct order.
You can verify this with a response.write stament follwing request.form for each field type. You will likely need to be more
explicit in naming form fields to create the desired association.

"MrHelpMe" <cl********@hotmail.comwrote in message news:11**********************@m7g2000cwm.googlegro ups.com...
Hello again experts,

I have successfully pulled data from an LDAP server and now what I want
to do is drop the data into a database table. The following is my code
that will insert the data but that has problems.

Expand|Select|Wrap|Line Numbers
  1.  FullName=Request.Form("Name")
  2.  Email=Request.Form("Email")
  3.  GivenName=Request.Form("GivenName")
  4.  StreetAddress=Request.Form("StreetAddress")
  5.  
  6.  FullNameDesc = Replace(FullName, "'", "''")
  7.  EmailDesc = Replace(Email, "'", "''")
  8.  GivenNameDesc = Replace(GivenName, "'", "''")
  9.  StreetAddressDesc = Replace(StreetAddress, "'", "''")
  10.  
  11.  strFullName = Split(FullNameDesc,", ")
  12.  strEmailName = Split(EmailDesc,", ")
  13.  strGivenName = Split(GivenNameDesc,", ")
  14.  strStreetAddress = Split(StreetAddressDesc,", ")
  15.  
  16.  Response.Buffer = True
  17.  Set objConn = Server.CreateObject("ADODB.Connection")
  18.  objConn.ConnectionString = (ConnectionInfoHidden)
  19.  objConn.Open
  20.  
  21.  For i = 0 to Ubound(strFullName)
  22.  sSQL = "INSERT into Users (FullName, Email, GivenName,Address)"
  23.  sSQL = sSQL & "VALUES ('" & strFullName(i) &"', '"& strEmailName(i)
  24.  &"', '" & strGivenName(i) &"', '" & strStreetAddress(i) &"')"
  25.  'objConn.Execute sSQL
  26.  
  27.  response.write sSql & "<BR>"
  28.  Next
  29.  
  30.  
What is happening is for each user the fullname, email, given name and
address should get successfully entered into the database table however
some fullnames are getting the incorrect email address, given name etc.
while others are correct. Can anyone see a problem? I have checked the
data that is coming back from ldap and my code is definitely incorrect.
Why do some users get incorrect info...it's almost like they are
getting the prior users info.
Oct 27 '06 #3
give each form field a specific unique name

FullName1=Request.Form("Name1")
"MrHelpMe" <cl********@hotmail.comwrote in message news:11********************@m73g2000cwd.googlegrou ps.com...
Jon,

Thanks for the reply. Is there any way you could show me this by
example? I'm still trying to learn asp and not sure what you mean by
"need to be more explicit in naming form fields". Does this require a
restructuring of my code? I was hoping to implement minimal changes to
my code. Could you possibly show me by using my exisiting code?
Thanks Jon.
Jon Paal wrote:
>when you do a request.form there's no assurance that all fields collection will arrive in a relatively correct order.
You can verify this with a response.write stament follwing request.form for each field type. You will likely need to be more
explicit in naming form fields to create the desired association.

"MrHelpMe" <cl********@hotmail.comwrote in message news:11**********************@m7g2000cwm.googlegro ups.com...
Hello again experts,

I have successfully pulled data from an LDAP server and now what I want
to do is drop the data into a database table. The following is my code
that will insert the data but that has problems.

Expand|Select|Wrap|Line Numbers
  1. FullName=Request.Form("Name")
  2. Email=Request.Form("Email")
  3. GivenName=Request.Form("GivenName")
  4. StreetAddress=Request.Form("StreetAddress")
  5. FullNameDesc = Replace(FullName, "'", "''")
  6. EmailDesc = Replace(Email, "'", "''")
  7. GivenNameDesc = Replace(GivenName, "'", "''")
  8. StreetAddressDesc = Replace(StreetAddress, "'", "''")
  9. strFullName = Split(FullNameDesc,", ")
  10. strEmailName = Split(EmailDesc,", ")
  11. strGivenName = Split(GivenNameDesc,", ")
  12. strStreetAddress = Split(StreetAddressDesc,", ")
  13. Response.Buffer = True
  14. Set objConn = Server.CreateObject("ADODB.Connection")
  15. objConn.ConnectionString = (ConnectionInfoHidden)
  16. objConn.Open
  17. For i = 0 to Ubound(strFullName)
  18. sSQL = "INSERT into Users (FullName, Email, GivenName,Address)"
  19. sSQL = sSQL & "VALUES ('" & strFullName(i) &"', '"& strEmailName(i)
  20. &"', '" & strGivenName(i) &"', '" & strStreetAddress(i) &"')"
  21. 'objConn.Execute sSQL
  22. response.write sSql & "<BR>"
  23. Next
  24.  

What is happening is for each user the fullname, email, given name and
address should get successfully entered into the database table however
some fullnames are getting the incorrect email address, given name etc.
while others are correct. Can anyone see a problem? I have checked the
data that is coming back from ldap and my code is definitely incorrect.
Why do some users get incorrect info...it's almost like they are
getting the prior users info.

Oct 27 '06 #4
That's exactly what I did as noted in the code shown.
Jon Paal wrote:
give each form field a specific unique name

FullName1=Request.Form("Name1")
"MrHelpMe" <cl********@hotmail.comwrote in message news:11********************@m73g2000cwd.googlegrou ps.com...
Jon,

Thanks for the reply. Is there any way you could show me this by
example? I'm still trying to learn asp and not sure what you mean by
"need to be more explicit in naming form fields". Does this require a
restructuring of my code? I was hoping to implement minimal changes to
my code. Could you possibly show me by using my exisiting code?
Thanks Jon.
Jon Paal wrote:
when you do a request.form there's no assurance that all fields collection will arrive in a relatively correct order.
You can verify this with a response.write stament follwing request.form for each field type. You will likely need to be more
explicit in naming form fields to create the desired association.

"MrHelpMe" <cl********@hotmail.comwrote in message news:11**********************@m7g2000cwm.googlegro ups.com...
Hello again experts,

I have successfully pulled data from an LDAP server and now what I want
to do is drop the data into a database table. The following is my code
that will insert the data but that has problems.

Expand|Select|Wrap|Line Numbers
  1.  FullName=Request.Form("Name")
  2.  Email=Request.Form("Email")
  3.  GivenName=Request.Form("GivenName")
  4.  StreetAddress=Request.Form("StreetAddress")
  5.  
  6.  FullNameDesc = Replace(FullName, "'", "''")
  7.  EmailDesc = Replace(Email, "'", "''")
  8.  GivenNameDesc = Replace(GivenName, "'", "''")
  9.  StreetAddressDesc = Replace(StreetAddress, "'", "''")
  10.  
  11.  strFullName = Split(FullNameDesc,", ")
  12.  strEmailName = Split(EmailDesc,", ")
  13.  strGivenName = Split(GivenNameDesc,", ")
  14.  strStreetAddress = Split(StreetAddressDesc,", ")
  15.  
  16.  Response.Buffer = True
  17.  Set objConn = Server.CreateObject("ADODB.Connection")
  18.  objConn.ConnectionString = (ConnectionInfoHidden)
  19.  objConn.Open
  20.  
  21.  For i = 0 to Ubound(strFullName)
  22.  sSQL = "INSERT into Users (FullName, Email, GivenName,Address)"
  23.  sSQL = sSQL & "VALUES ('" & strFullName(i) &"', '"& strEmailName(i)
  24.  &"', '" & strGivenName(i) &"', '" & strStreetAddress(i) &"')"
  25.  'objConn.Execute sSQL
  26.  
  27.  response.write sSql & "<BR>"
  28.  Next
  29.  
  30.  
What is happening is for each user the fullname, email, given name and
address should get successfully entered into the database table however
some fullnames are getting the incorrect email address, given name etc.
while others are correct. Can anyone see a problem? I have checked the
data that is coming back from ldap and my code is definitely incorrect.
Why do some users get incorrect info...it's almost like they are
getting the prior users info.
Oct 27 '06 #5
if it is unique then why are you splitting it ?
"MrHelpMe" <cl********@hotmail.comwrote in message news:11*********************@b28g2000cwb.googlegro ups.com...
That's exactly what I did as noted in the code shown.
Jon Paal wrote:
>give each form field a specific unique name

FullName1=Request.Form("Name1")
"MrHelpMe" <cl********@hotmail.comwrote in message news:11********************@m73g2000cwd.googlegrou ps.com...
Jon,

Thanks for the reply. Is there any way you could show me this by
example? I'm still trying to learn asp and not sure what you mean by
"need to be more explicit in naming form fields". Does this require a
restructuring of my code? I was hoping to implement minimal changes to
my code. Could you possibly show me by using my exisiting code?
Thanks Jon.
Jon Paal wrote:
when you do a request.form there's no assurance that all fields collection will arrive in a relatively correct order.
You can verify this with a response.write stament follwing request.form for each field type. You will likely need to be more
explicit in naming form fields to create the desired association.

"MrHelpMe" <cl********@hotmail.comwrote in message news:11**********************@m7g2000cwm.googlegro ups.com...
Hello again experts,

I have successfully pulled data from an LDAP server and now what I want
to do is drop the data into a database table. The following is my code
that will insert the data but that has problems.

Expand|Select|Wrap|Line Numbers
  1. FullName=Request.Form("Name")
  2. Email=Request.Form("Email")
  3. GivenName=Request.Form("GivenName")
  4. StreetAddress=Request.Form("StreetAddress")
  5. FullNameDesc = Replace(FullName, "'", "''")
  6. EmailDesc = Replace(Email, "'", "''")
  7. GivenNameDesc = Replace(GivenName, "'", "''")
  8. StreetAddressDesc = Replace(StreetAddress, "'", "''")
  9. strFullName = Split(FullNameDesc,", ")
  10. strEmailName = Split(EmailDesc,", ")
  11. strGivenName = Split(GivenNameDesc,", ")
  12. strStreetAddress = Split(StreetAddressDesc,", ")
  13. Response.Buffer = True
  14. Set objConn = Server.CreateObject("ADODB.Connection")
  15. objConn.ConnectionString = (ConnectionInfoHidden)
  16. objConn.Open
  17. For i = 0 to Ubound(strFullName)
  18. sSQL = "INSERT into Users (FullName, Email, GivenName,Address)"
  19. sSQL = sSQL & "VALUES ('" & strFullName(i) &"', '"& strEmailName(i)
  20. &"', '" & strGivenName(i) &"', '" & strStreetAddress(i) &"')"
  21. 'objConn.Execute sSQL
  22. response.write sSql & "<BR>"
  23. Next
  24.  

What is happening is for each user the fullname, email, given name and
address should get successfully entered into the database table however
some fullnames are getting the incorrect email address, given name etc.
while others are correct. Can anyone see a problem? I have checked the
data that is coming back from ldap and my code is definitely incorrect.
Why do some users get incorrect info...it's almost like they are
getting the prior users info.


Oct 27 '06 #6
What is happening is the data is being returned from a select on an
LDAP server. Then I am looping thorugh the recordeset and returning the
objectrecordset of each field. What I am left with is for each field I
have a string of comma separated list that I would need to split so
that is why.
I Jon Paal wrote:
if it is unique then why are you splitting it ?
"MrHelpMe" <cl********@hotmail.comwrote in message news:11*********************@b28g2000cwb.googlegro ups.com...
That's exactly what I did as noted in the code shown.
Jon Paal wrote:
give each form field a specific unique name

FullName1=Request.Form("Name1")
"MrHelpMe" <cl********@hotmail.comwrote in message news:11********************@m73g2000cwd.googlegrou ps.com...
Jon,

Thanks for the reply. Is there any way you could show me this by
example? I'm still trying to learn asp and not sure what you mean by
"need to be more explicit in naming form fields". Does this require a
restructuring of my code? I was hoping to implement minimal changes to
my code. Could you possibly show me by using my exisiting code?
Thanks Jon.
Jon Paal wrote:
when you do a request.form there's no assurance that all fields collection will arrive in a relatively correct order.
You can verify this with a response.write stament follwing request.form for each field type. You will likely need to be more
explicit in naming form fields to create the desired association.

"MrHelpMe" <cl********@hotmail.comwrote in message news:11**********************@m7g2000cwm.googlegro ups.com...
Hello again experts,

I have successfully pulled data from an LDAP server and now what I want
to do is drop the data into a database table. The following is my code
that will insert the data but that has problems.

Expand|Select|Wrap|Line Numbers
  1.  FullName=Request.Form("Name")
  2.  Email=Request.Form("Email")
  3.  GivenName=Request.Form("GivenName")
  4.  StreetAddress=Request.Form("StreetAddress")
  5.  
  6.  FullNameDesc = Replace(FullName, "'", "''")
  7.  EmailDesc = Replace(Email, "'", "''")
  8.  GivenNameDesc = Replace(GivenName, "'", "''")
  9.  StreetAddressDesc = Replace(StreetAddress, "'", "''")
  10.  
  11.  strFullName = Split(FullNameDesc,", ")
  12.  strEmailName = Split(EmailDesc,", ")
  13.  strGivenName = Split(GivenNameDesc,", ")
  14.  strStreetAddress = Split(StreetAddressDesc,", ")
  15.  
  16.  Response.Buffer = True
  17.  Set objConn = Server.CreateObject("ADODB.Connection")
  18.  objConn.ConnectionString = (ConnectionInfoHidden)
  19.  objConn.Open
  20.  
  21.  For i = 0 to Ubound(strFullName)
  22.  sSQL = "INSERT into Users (FullName, Email, GivenName,Address)"
  23.  sSQL = sSQL & "VALUES ('" & strFullName(i) &"', '"& strEmailName(i)
  24.  &"', '" & strGivenName(i) &"', '" & strStreetAddress(i) &"')"
  25.  'objConn.Execute sSQL
  26.  
  27.  response.write sSql & "<BR>"
  28.  Next
  29.  
  30.  
What is happening is for each user the fullname, email, given name and
address should get successfully entered into the database table however
some fullnames are getting the incorrect email address, given name etc.
while others are correct. Can anyone see a problem? I have checked the
data that is coming back from ldap and my code is definitely incorrect.
Why do some users get incorrect info...it's almost like they are
getting the prior users info.
Oct 27 '06 #7
I can only cvomment based upon what you have provided. Your code indicates it is coming from a form ("request.form").

You can't allow multiple select of names and multiple select of emails and somehow hope they correspond to each other in the correct
order.

there is nothing unique here, there is a collection of values which are split.
FullName=Request.Form("Name")
FullNameDesc = Replace(FullName, "'", "''")
strFullName = Split(FullNameDesc,", ")
the resulting strFullName array is not likely to match with resulting array of emails in the correct order.

you either need to have unique names or an association value to correlate name with the intended email etc.
"MrHelpMe" <cl********@hotmail.comwrote in message news:11**********************@i42g2000cwa.googlegr oups.com...
What is happening is the data is being returned from a select on an
LDAP server. Then I am looping thorugh the recordeset and returning the
objectrecordset of each field. What I am left with is for each field I
have a string of comma separated list that I would need to split so
that is why.
I Jon Paal wrote:
>if it is unique then why are you splitting it ?
"MrHelpMe" <cl********@hotmail.comwrote in message news:11*********************@b28g2000cwb.googlegro ups.com...
That's exactly what I did as noted in the code shown.
Jon Paal wrote:
give each form field a specific unique name

FullName1=Request.Form("Name1")
"MrHelpMe" <cl********@hotmail.comwrote in message news:11********************@m73g2000cwd.googlegrou ps.com...
Jon,

Thanks for the reply. Is there any way you could show me this by
example? I'm still trying to learn asp and not sure what you mean by
"need to be more explicit in naming form fields". Does this require a
restructuring of my code? I was hoping to implement minimal changes to
my code. Could you possibly show me by using my exisiting code?
Thanks Jon.
Jon Paal wrote:
when you do a request.form there's no assurance that all fields collection will arrive in a relatively correct order.
You can verify this with a response.write stament follwing request.form for each field type. You will likely need to be
more
explicit in naming form fields to create the desired association.

"MrHelpMe" <cl********@hotmail.comwrote in message news:11**********************@m7g2000cwm.googlegro ups.com...
Hello again experts,

I have successfully pulled data from an LDAP server and now what I want
to do is drop the data into a database table. The following is my code
that will insert the data but that has problems.

Expand|Select|Wrap|Line Numbers
  1. FullName=Request.Form("Name")
  2. Email=Request.Form("Email")
  3. GivenName=Request.Form("GivenName")
  4. StreetAddress=Request.Form("StreetAddress")
  5. FullNameDesc = Replace(FullName, "'", "''")
  6. EmailDesc = Replace(Email, "'", "''")
  7. GivenNameDesc = Replace(GivenName, "'", "''")
  8. StreetAddressDesc = Replace(StreetAddress, "'", "''")
  9. strFullName = Split(FullNameDesc,", ")
  10. strEmailName = Split(EmailDesc,", ")
  11. strGivenName = Split(GivenNameDesc,", ")
  12. strStreetAddress = Split(StreetAddressDesc,", ")
  13. Response.Buffer = True
  14. Set objConn = Server.CreateObject("ADODB.Connection")
  15. objConn.ConnectionString = (ConnectionInfoHidden)
  16. objConn.Open
  17. For i = 0 to Ubound(strFullName)
  18. sSQL = "INSERT into Users (FullName, Email, GivenName,Address)"
  19. sSQL = sSQL & "VALUES ('" & strFullName(i) &"', '"& strEmailName(i)
  20. &"', '" & strGivenName(i) &"', '" & strStreetAddress(i) &"')"
  21. 'objConn.Execute sSQL
  22. response.write sSql & "<BR>"
  23. Next
  24.  

What is happening is for each user the fullname, email, given name and
address should get successfully entered into the database table however
some fullnames are getting the incorrect email address, given name etc.
while others are correct. Can anyone see a problem? I have checked the
data that is coming back from ldap and my code is definitely incorrect.
Why do some users get incorrect info...it's almost like they are
getting the prior users info.

Oct 27 '06 #8
Jon,

I do see what you mean but not understanding how to fix this with code.
Your last statement "you either need to have unique names or an
association value to correlate name with the intended email etc" could
you show me how I would fix this please. Could you possible show me
with some code? Thanks again for your help Jon.
Jon Paal wrote:
I can only cvomment based upon what you have provided. Your code indicates it is coming from a form ("request.form").

You can't allow multiple select of names and multiple select of emails and somehow hope they correspond to each other in the correct
order.

there is nothing unique here, there is a collection of values which are split.
FullName=Request.Form("Name")
FullNameDesc = Replace(FullName, "'", "''")
strFullName = Split(FullNameDesc,", ")

the resulting strFullName array is not likely to match with resulting array of emails in the correct order.

you either need to have unique names or an association value to correlate name with the intended email etc.
"MrHelpMe" <cl********@hotmail.comwrote in message news:11**********************@i42g2000cwa.googlegr oups.com...
What is happening is the data is being returned from a select on an
LDAP server. Then I am looping thorugh the recordeset and returning the
objectrecordset of each field. What I am left with is for each field I
have a string of comma separated list that I would need to split so
that is why.
I Jon Paal wrote:
if it is unique then why are you splitting it ?
"MrHelpMe" <cl********@hotmail.comwrote in message news:11*********************@b28g2000cwb.googlegro ups.com...
That's exactly what I did as noted in the code shown.
Jon Paal wrote:
give each form field a specific unique name

FullName1=Request.Form("Name1")
"MrHelpMe" <cl********@hotmail.comwrote in message news:11********************@m73g2000cwd.googlegrou ps.com...
Jon,

Thanks for the reply. Is there any way you could show me this by
example? I'm still trying to learn asp and not sure what you mean by
"need to be more explicit in naming form fields". Does this require a
restructuring of my code? I was hoping to implement minimal changes to
my code. Could you possibly show me by using my exisiting code?
Thanks Jon.
Jon Paal wrote:
when you do a request.form there's no assurance that all fields collection will arrive in a relatively correct order.
You can verify this with a response.write stament follwing request.form for each field type. You will likely need to be
more
explicit in naming form fields to create the desired association.

"MrHelpMe" <cl********@hotmail.comwrote in message news:11**********************@m7g2000cwm.googlegro ups.com...
Hello again experts,

I have successfully pulled data from an LDAP server and now what I want
to do is drop the data into a database table. The following is my code
that will insert the data but that has problems.

Expand|Select|Wrap|Line Numbers
  1.  FullName=Request.Form("Name")
  2.  Email=Request.Form("Email")
  3.  GivenName=Request.Form("GivenName")
  4.  StreetAddress=Request.Form("StreetAddress")
  5.  
  6.  FullNameDesc = Replace(FullName, "'", "''")
  7.  EmailDesc = Replace(Email, "'", "''")
  8.  GivenNameDesc = Replace(GivenName, "'", "''")
  9.  StreetAddressDesc = Replace(StreetAddress, "'", "''")
  10.  
  11.  strFullName = Split(FullNameDesc,", ")
  12.  strEmailName = Split(EmailDesc,", ")
  13.  strGivenName = Split(GivenNameDesc,", ")
  14.  strStreetAddress = Split(StreetAddressDesc,", ")
  15.  
  16.  Response.Buffer = True
  17.  Set objConn = Server.CreateObject("ADODB.Connection")
  18.  objConn.ConnectionString = (ConnectionInfoHidden)
  19.  objConn.Open
  20.  
  21.  For i = 0 to Ubound(strFullName)
  22.  sSQL = "INSERT into Users (FullName, Email, GivenName,Address)"
  23.  sSQL = sSQL & "VALUES ('" & strFullName(i) &"', '"& strEmailName(i)
  24.  &"', '" & strGivenName(i) &"', '" & strStreetAddress(i) &"')"
  25.  'objConn.Execute sSQL
  26.  
  27.  response.write sSql & "<BR>"
  28.  Next
  29.  
  30.  
What is happening is for each user the fullname, email, given name and
address should get successfully entered into the database table however
some fullnames are getting the incorrect email address, given name etc.
while others are correct. Can anyone see a problem? I have checked the
data that is coming back from ldap and my code is definitely incorrect.
Why do some users get incorrect info...it's almost like they are
getting the prior users info.

Oct 27 '06 #9
I believe the solution is to change your form and the processing page

--give each value in the form a unique name.

<INPUT
TYPE="text"
NAME="Name1">
--on the processing page retrieve that value by name.
FullName1 = request.form("name1")

--rinse.. repeat as needed for all fields



"MrHelpMe" <cl********@hotmail.comwrote in message news:11*********************@h48g2000cwc.googlegro ups.com...
Jon,

I do see what you mean but not understanding how to fix this with code.
Your last statement "you either need to have unique names or an
association value to correlate name with the intended email etc" could
you show me how I would fix this please. Could you possible show me
with some code? Thanks again for your help Jon.
Jon Paal wrote:
>I can only cvomment based upon what you have provided. Your code indicates it is coming from a form ("request.form").

You can't allow multiple select of names and multiple select of emails and somehow hope they correspond to each other in the
correct
order.

there is nothing unique here, there is a collection of values which are split.
> FullName=Request.Form("Name")
FullNameDesc = Replace(FullName, "'", "''")
strFullName = Split(FullNameDesc,", ")

the resulting strFullName array is not likely to match with resulting array of emails in the correct order.

you either need to have unique names or an association value to correlate name with the intended email etc.
"MrHelpMe" <cl********@hotmail.comwrote in message news:11**********************@i42g2000cwa.googlegr oups.com...
What is happening is the data is being returned from a select on an
LDAP server. Then I am looping thorugh the recordeset and returning the
objectrecordset of each field. What I am left with is for each field I
have a string of comma separated list that I would need to split so
that is why.
I Jon Paal wrote:
if it is unique then why are you splitting it ?
"MrHelpMe" <cl********@hotmail.comwrote in message news:11*********************@b28g2000cwb.googlegro ups.com...
That's exactly what I did as noted in the code shown.
Jon Paal wrote:
give each form field a specific unique name

FullName1=Request.Form("Name1")
"MrHelpMe" <cl********@hotmail.comwrote in message news:11********************@m73g2000cwd.googlegrou ps.com...
Jon,

Thanks for the reply. Is there any way you could show me this by
example? I'm still trying to learn asp and not sure what you mean by
"need to be more explicit in naming form fields". Does this require a
restructuring of my code? I was hoping to implement minimal changes to
my code. Could you possibly show me by using my exisiting code?
Thanks Jon.
Jon Paal wrote:
when you do a request.form there's no assurance that all fields collection will arrive in a relatively correct order.
You can verify this with a response.write stament follwing request.form for each field type. You will likely need to
be
more
explicit in naming form fields to create the desired association.

"MrHelpMe" <cl********@hotmail.comwrote in message news:11**********************@m7g2000cwm.googlegro ups.com...
Hello again experts,

I have successfully pulled data from an LDAP server and now what I want
to do is drop the data into a database table. The following is my code
that will insert the data but that has problems.

Expand|Select|Wrap|Line Numbers
  1. FullName=Request.Form("Name")
  2. Email=Request.Form("Email")
  3. GivenName=Request.Form("GivenName")
  4. StreetAddress=Request.Form("StreetAddress")
  5. FullNameDesc = Replace(FullName, "'", "''")
  6. EmailDesc = Replace(Email, "'", "''")
  7. GivenNameDesc = Replace(GivenName, "'", "''")
  8. StreetAddressDesc = Replace(StreetAddress, "'", "''")
  9. strFullName = Split(FullNameDesc,", ")
  10. strEmailName = Split(EmailDesc,", ")
  11. strGivenName = Split(GivenNameDesc,", ")
  12. strStreetAddress = Split(StreetAddressDesc,", ")
  13. Response.Buffer = True
  14. Set objConn = Server.CreateObject("ADODB.Connection")
  15. objConn.ConnectionString = (ConnectionInfoHidden)
  16. objConn.Open
  17. For i = 0 to Ubound(strFullName)
  18. sSQL = "INSERT into Users (FullName, Email, GivenName,Address)"
  19. sSQL = sSQL & "VALUES ('" & strFullName(i) &"', '"& strEmailName(i)
  20. &"', '" & strGivenName(i) &"', '" & strStreetAddress(i) &"')"
  21. 'objConn.Execute sSQL
  22. response.write sSql & "<BR>"
  23. Next
  24.  

What is happening is for each user the fullname, email, given name and
address should get successfully entered into the database table however
some fullnames are getting the incorrect email address, given name etc.
while others are correct. Can anyone see a problem? I have checked the
data that is coming back from ldap and my code is definitely incorrect.
Why do some users get incorrect info...it's almost like they are
getting the prior users info.


Oct 28 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Christopher Ambler | last post by:
This is long, but it's driving me nuts. I need some adult supervision :-) (and I'm not above bribing for help) I have a stored procedure that I call that returns XML to me. The SP returns 3...
0
by: Shaggyh | last post by:
hi im needing help with a program im writing to do subnetting i was on before about it and i got some help. the code below wont work for me and i cant think of why not. i was wondering if anyone...
4
by: Cor | last post by:
Hi Newsgroup, I have given an answer in this newsgroup about a "Replace". There came an answer on that I did not understand, so I have done some tests. I got the idea that someone said,...
8
by: moondaddy | last post by:
I'm writing an app in vb.net 1.1 and I need to parse strings that look similar to the one below. All 5 rows will make up one string. I have a form where a use can copy/paste data like what you...
43
by: SLH | last post by:
hi people. im trying to validate input received via a text area on an ASP page before writing it to a database. i cant use client side javascript due to policy, so it all has to happen on the...
1
by: rporter | last post by:
I have a javascript utility and need so help with regular expressions.. Basically I have lines of data that consists of name=value pairs delimited with commas. example match=type...
4
by: thesinnerishere | last post by:
i have created a program(link-generator) which is static in nature(it works correctly) meaning that this program must find the symbol { } first for it to operate properly.how can i make it dynamic so...
2
by: WP | last post by:
Hello, below is my very first python program. I have some questions regarding it and would like comments in general. I won't be able to get my hands on a good python book until tomorrow at the...
5
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.