By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,664 Members | 1,970 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,664 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
9 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.