Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > need more help on split, replace and inserting into a databse

Reply
Thread Tools

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

 
 
MrHelpMe
Guest
Posts: n/a
 
      10-27-2006
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.

Code:
FullName=Request.Form("Name")
Email=Request.Form("Email")
GivenName=Request.Form("GivenName")
StreetAddress=Request.Form("StreetAddress")

FullNameDesc = Replace(FullName, "'", "''")
EmailDesc = Replace(Email, "'", "''")
GivenNameDesc = Replace(GivenName, "'", "''")
StreetAddressDesc = Replace(StreetAddress, "'", "''")

strFullName = Split(FullNameDesc,", ")
strEmailName = Split(EmailDesc,", ")
strGivenName = Split(GivenNameDesc,", ")
strStreetAddress = Split(StreetAddressDesc,", ")

Response.Buffer = True
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = (ConnectionInfoHidden)
objConn.Open

For i = 0 to Ubound(strFullName)
sSQL = "INSERT into Users (FullName, Email, GivenName,Address)"
sSQL = sSQL & "VALUES ('" & strFullName(i) &"', '"& strEmailName(i)
&"', '" & strGivenName(i) &"', '" & strStreetAddress(i) &"')"
'objConn.Execute sSQL

response.write sSql & "<BR>"
Next
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.

 
Reply With Quote
 
 
 
 
MrHelpMe
Guest
Posts: n/a
 
      10-27-2006
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed) 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.
> >
> >
Code:
> > FullName=Request.Form("Name")
> > Email=Request.Form("Email")
> > GivenName=Request.Form("GivenName")
> > StreetAddress=Request.Form("StreetAddress")
> >
> > FullNameDesc = Replace(FullName, "'", "''")
> > EmailDesc = Replace(Email, "'", "''")
> > GivenNameDesc = Replace(GivenName, "'", "''")
> > StreetAddressDesc = Replace(StreetAddress, "'", "''")
> >
> > strFullName = Split(FullNameDesc,", ")
> > strEmailName = Split(EmailDesc,", ")
> > strGivenName = Split(GivenNameDesc,", ")
> > strStreetAddress = Split(StreetAddressDesc,", ")
> >
> > Response.Buffer = True
> > Set objConn = Server.CreateObject("ADODB.Connection")
> > objConn.ConnectionString = (ConnectionInfoHidden)
> > objConn.Open
> >
> > For i = 0 to Ubound(strFullName)
> > sSQL = "INSERT into Users (FullName, Email, GivenName,Address)"
> > sSQL = sSQL & "VALUES ('" & strFullName(i) &"', '"& strEmailName(i)
> > &"', '" & strGivenName(i) &"', '" & strStreetAddress(i) &"')"
> > 'objConn.Execute sSQL
> >
> > response.write sSql & "<BR>"
> > Next
> >
> >
> >
> > 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.
> >


 
Reply With Quote
 
 
 
 
MrHelpMe
Guest
Posts: n/a
 
      10-27-2006
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed) 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed) 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.
> >> >
> >> >
Code:
> >> > FullName=Request.Form("Name")
> >> > Email=Request.Form("Email")
> >> > GivenName=Request.Form("GivenName")
> >> > StreetAddress=Request.Form("StreetAddress")
> >> >
> >> > FullNameDesc = Replace(FullName, "'", "''")
> >> > EmailDesc = Replace(Email, "'", "''")
> >> > GivenNameDesc = Replace(GivenName, "'", "''")
> >> > StreetAddressDesc = Replace(StreetAddress, "'", "''")
> >> >
> >> > strFullName = Split(FullNameDesc,", ")
> >> > strEmailName = Split(EmailDesc,", ")
> >> > strGivenName = Split(GivenNameDesc,", ")
> >> > strStreetAddress = Split(StreetAddressDesc,", ")
> >> >
> >> > Response.Buffer = True
> >> > Set objConn = Server.CreateObject("ADODB.Connection")
> >> > objConn.ConnectionString = (ConnectionInfoHidden)
> >> > objConn.Open
> >> >
> >> > For i = 0 to Ubound(strFullName)
> >> > sSQL = "INSERT into Users (FullName, Email, GivenName,Address)"
> >> > sSQL = sSQL & "VALUES ('" & strFullName(i) &"', '"& strEmailName(i)
> >> > &"', '" & strGivenName(i) &"', '" & strStreetAddress(i) &"')"
> >> > 'objConn.Execute sSQL
> >> >
> >> > response.write sSql & "<BR>"
> >> > Next
> >> >
> >> >
> >> >
> >> > 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.
> >> >

> >


 
Reply With Quote
 
MrHelpMe
Guest
Posts: n/a
 
      10-27-2006
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed) 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed) 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed) 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.
> >> >> >
> >> >> >
Code:
> >> >> > FullName=Request.Form("Name")
> >> >> > Email=Request.Form("Email")
> >> >> > GivenName=Request.Form("GivenName")
> >> >> > StreetAddress=Request.Form("StreetAddress")
> >> >> >
> >> >> > FullNameDesc = Replace(FullName, "'", "''")
> >> >> > EmailDesc = Replace(Email, "'", "''")
> >> >> > GivenNameDesc = Replace(GivenName, "'", "''")
> >> >> > StreetAddressDesc = Replace(StreetAddress, "'", "''")
> >> >> >
> >> >> > strFullName = Split(FullNameDesc,", ")
> >> >> > strEmailName = Split(EmailDesc,", ")
> >> >> > strGivenName = Split(GivenNameDesc,", ")
> >> >> > strStreetAddress = Split(StreetAddressDesc,", ")
> >> >> >
> >> >> > Response.Buffer = True
> >> >> > Set objConn = Server.CreateObject("ADODB.Connection")
> >> >> > objConn.ConnectionString = (ConnectionInfoHidden)
> >> >> > objConn.Open
> >> >> >
> >> >> > For i = 0 to Ubound(strFullName)
> >> >> > sSQL = "INSERT into Users (FullName, Email, GivenName,Address)"
> >> >> > sSQL = sSQL & "VALUES ('" & strFullName(i) &"', '"& strEmailName(i)
> >> >> > &"', '" & strGivenName(i) &"', '" & strStreetAddress(i) &"')"
> >> >> > 'objConn.Execute sSQL
> >> >> >
> >> >> > response.write sSql & "<BR>"
> >> >> > Next
> >> >> >
> >> >> >
> >> >> >
> >> >> > 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.
> >> >> >
> >> >

> >


 
Reply With Quote
 
MrHelpMe
Guest
Posts: n/a
 
      10-27-2006
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed) 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed) 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed) 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed) 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.
> >> >> >> >
> >> >> >> >
Code:
> >> >> >> > FullName=Request.Form("Name")
> >> >> >> > Email=Request.Form("Email")
> >> >> >> > GivenName=Request.Form("GivenName")
> >> >> >> > StreetAddress=Request.Form("StreetAddress")
> >> >> >> >
> >> >> >> > FullNameDesc = Replace(FullName, "'", "''")
> >> >> >> > EmailDesc = Replace(Email, "'", "''")
> >> >> >> > GivenNameDesc = Replace(GivenName, "'", "''")
> >> >> >> > StreetAddressDesc = Replace(StreetAddress, "'", "''")
> >> >> >> >
> >> >> >> > strFullName = Split(FullNameDesc,", ")
> >> >> >> > strEmailName = Split(EmailDesc,", ")
> >> >> >> > strGivenName = Split(GivenNameDesc,", ")
> >> >> >> > strStreetAddress = Split(StreetAddressDesc,", ")
> >> >> >> >
> >> >> >> > Response.Buffer = True
> >> >> >> > Set objConn = Server.CreateObject("ADODB.Connection")
> >> >> >> > objConn.ConnectionString = (ConnectionInfoHidden)
> >> >> >> > objConn.Open
> >> >> >> >
> >> >> >> > For i = 0 to Ubound(strFullName)
> >> >> >> > sSQL = "INSERT into Users (FullName, Email, GivenName,Address)"
> >> >> >> > sSQL = sSQL & "VALUES ('" & strFullName(i) &"', '"& strEmailName(i)
> >> >> >> > &"', '" & strGivenName(i) &"', '" & strStreetAddress(i) &"')"
> >> >> >> > 'objConn.Execute sSQL
> >> >> >> >
> >> >> >> > response.write sSql & "<BR>"
> >> >> >> > Next
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >> >> > 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.
> >> >> >> >
> >> >> >
> >> >

> >


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
insert values into databse using sqlserverstoredprocedure with asp.net Sirisha ASP .Net 1 02-20-2007 09:09 AM
Set a bgcolor in a repeater based on databse value asp newbie Jim Florence ASP .Net 4 06-24-2006 12:18 PM
q: design a web and databse JIM.H. ASP .Net 2 02-13-2005 10:06 PM
Re: Connecting my application to a SQL Server-databse Ashish M Bhonkiya ASP .Net 0 05-05-2004 05:17 AM
non-form based databse application sreenivasan alakappan C++ 6 04-08-2004 02:24 AM



Advertisments