473,511 Members | 14,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using Arrays to write data to SQL Server

I'm trying to write data from a form using a text box (textarea) that
has a return after each item. For example:

em****@domain.com
em****@domain.com
em****@domain.com
em****@domain.com

I'm getting the data written to the SQL server table fine, but every
item after the first is getting written with a special character
preceeding the email address that looks like a little box. What is
it, why is their there and how do I remove it?

Here is my code:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim varItems, varArray, I
varItems = Request("email_address")
varArray = Split(varItems,chr(13))

For I = LBound(varArray) To UBound(varArray)

'write data to database

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "driver={SQL Server};server=aaaaaaa;"
SQLStmt = "INSERT INTO tbl_advertisers (email_address) "
SQLStmt = SQLStmt & "VALUES ('" & varArray(I) & "')"
Set RS = Conn.Execute(SQLStmt)
set rs=nothing

If err.number>0 then
response.write "VBScript Errors Occured:" & "<P>"
response.write "Error Number=" & err.number & "<P>"
response.write "Error Descr.=" & err.description & "<P>"
response.write "Help Context=" & err.helpcontext & "<P>"
response.write "Help Path=" & err.helppath & "<P>"
response.write "Native Error=" & err.nativeerror & "<P>"
response.write "Source=" & err.source & "<P>"
response.write "SQLState=" & err.sqlstate & "<P>"
end if
IF conn.errors.count0 then
response.write "Database Errors Occured" & "<P>"
response.write SQLstmt & "<P>"
for counter= 0 to conn.errors.count
response.write "Error #" & conn.errors(counter).number & "<P>"
response.write "Error desc. -" & conn.errors(counter).description &
"<P>"
next
else
end if
Conn.Close
set conn=nothing

Next 'I
%>
Thanks.

Brett

Feb 1 '07 #1
3 3879

"Brett_A" <br********@gmail.comwrote in message
news:11**********************@l53g2000cwa.googlegr oups.com...
I'm trying to write data from a form using a text box (textarea) that
has a return after each item. For example:

em****@domain.com
em****@domain.com
em****@domain.com
em****@domain.com

I'm getting the data written to the SQL server table fine, but every
item after the first is getting written with a special character
preceeding the email address that looks like a little box. What is
it, why is their there and how do I remove it?

Here is my code:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim varItems, varArray, I
varItems = Request("email_address")
varArray = Split(varItems,chr(13))

For I = LBound(varArray) To UBound(varArray)

'write data to database

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "driver={SQL Server};server=aaaaaaa;"
SQLStmt = "INSERT INTO tbl_advertisers (email_address) "
SQLStmt = SQLStmt & "VALUES ('" & varArray(I) & "')"
Set RS = Conn.Execute(SQLStmt)
set rs=nothing

If err.number>0 then
response.write "VBScript Errors Occured:" & "<P>"
response.write "Error Number=" & err.number & "<P>"
response.write "Error Descr.=" & err.description & "<P>"
response.write "Help Context=" & err.helpcontext & "<P>"
response.write "Help Path=" & err.helppath & "<P>"
response.write "Native Error=" & err.nativeerror & "<P>"
response.write "Source=" & err.source & "<P>"
response.write "SQLState=" & err.sqlstate & "<P>"
end if
IF conn.errors.count0 then
response.write "Database Errors Occured" & "<P>"
response.write SQLstmt & "<P>"
for counter= 0 to conn.errors.count
response.write "Error #" & conn.errors(counter).number & "<P>"
response.write "Error desc. -" & conn.errors(counter).description &
"<P>"
next
else
end if
Conn.Close
set conn=nothing

Next 'I
%>
Thanks.

Brett
I supect you have a vbcrlf - Chr(13) & Chr(10) at the end of each line,
your split leaves behind the Chr(10)
--
John Blessing

http://www.LbeHelpdesk.com - Help Desk software priced to suit all
businesses
http://www.room-booking-software.com - Schedule rooms & equipment bookings
for your meeting/class over the web.
http://www.lbetoolbox.com - Remove Duplicates from MS Outlook, find/replace,
send newsletters
Feb 1 '07 #2
On Feb 1, 10:36 am, "John Blessing"
<blessij@**REMOVE**THIS**gmail.comwrote:
"Brett_A" <brettat...@gmail.comwrote in message

news:11**********************@l53g2000cwa.googlegr oups.com...
I'm trying to write data from a form using a text box (textarea) that
has a return after each item. For example:
ema...@domain.com
ema...@domain.com
ema...@domain.com
ema...@domain.com
I'm getting the data written to the SQL server table fine, but every
item after the first is getting written with a special character
preceeding the email address that looks like a little box. What is
it, why is their there and how do I remove it?
Here is my code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim varItems, varArray, I
varItems = Request("email_address")
varArray = Split(varItems,chr(13))
For I = LBound(varArray) To UBound(varArray)
'write data to database
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "driver={SQL Server};server=aaaaaaa;"
SQLStmt = "INSERT INTO tbl_advertisers (email_address) "
SQLStmt = SQLStmt & "VALUES ('" & varArray(I) & "')"
Set RS = Conn.Execute(SQLStmt)
set rs=nothing
If err.number>0 then
response.write "VBScript Errors Occured:" & "<P>"
response.write "Error Number=" & err.number & "<P>"
response.write "Error Descr.=" & err.description & "<P>"
response.write "Help Context=" & err.helpcontext & "<P>"
response.write "Help Path=" & err.helppath & "<P>"
response.write "Native Error=" & err.nativeerror & "<P>"
response.write "Source=" & err.source & "<P>"
response.write "SQLState=" & err.sqlstate & "<P>"
end if
IF conn.errors.count0 then
response.write "Database Errors Occured" & "<P>"
response.write SQLstmt & "<P>"
for counter= 0 to conn.errors.count
response.write "Error #" & conn.errors(counter).number & "<P>"
response.write "Error desc. -" & conn.errors(counter).description &
"<P>"
next
else
end if
Conn.Close
set conn=nothing
Next 'I
%>
Thanks.
Brett

I supect you have a vbcrlf - Chr(13) & Chr(10) at the end of each line,
your split leaves behind the Chr(10)

--
John Blessing

http://www.LbeHelpdesk.com- Help Desk software priced to suit all
businesseshttp://www.room-booking-software.com- Schedule rooms & equipment bookings
for your meeting/class over the web.http://www.lbetoolbox.com- Remove Duplicates from MS Outlook, find/replace,
send newsletters

That fixed it John, thanks.

Brett

Feb 1 '07 #3

The reason you are getting that symbol is because you are splitting the text
incorrectly. By splitting it with the Chr(13), you are forgetting that a new
line is Chr(13) + Chr(10).

The best way is to replace that line with the following:
varArray = Split(varItems, vbNewLine)

Your problem should be fixed.


"Brett_A" <br********@gmail.comwrote in message
news:11**********************@l53g2000cwa.googlegr oups.com...
I'm trying to write data from a form using a text box (textarea) that
has a return after each item. For example:

em****@domain.com
em****@domain.com
em****@domain.com
em****@domain.com

I'm getting the data written to the SQL server table fine, but every
item after the first is getting written with a special character
preceeding the email address that looks like a little box. What is
it, why is their there and how do I remove it?

Here is my code:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim varItems, varArray, I
varItems = Request("email_address")
varArray = Split(varItems,chr(13))

For I = LBound(varArray) To UBound(varArray)

'write data to database

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "driver={SQL Server};server=aaaaaaa;"
SQLStmt = "INSERT INTO tbl_advertisers (email_address) "
SQLStmt = SQLStmt & "VALUES ('" & varArray(I) & "')"
Set RS = Conn.Execute(SQLStmt)
set rs=nothing

If err.number>0 then
response.write "VBScript Errors Occured:" & "<P>"
response.write "Error Number=" & err.number & "<P>"
response.write "Error Descr.=" & err.description & "<P>"
response.write "Help Context=" & err.helpcontext & "<P>"
response.write "Help Path=" & err.helppath & "<P>"
response.write "Native Error=" & err.nativeerror & "<P>"
response.write "Source=" & err.source & "<P>"
response.write "SQLState=" & err.sqlstate & "<P>"
end if
IF conn.errors.count0 then
response.write "Database Errors Occured" & "<P>"
response.write SQLstmt & "<P>"
for counter= 0 to conn.errors.count
response.write "Error #" & conn.errors(counter).number & "<P>"
response.write "Error desc. -" & conn.errors(counter).description &
"<P>"
next
else
end if
Conn.Close
set conn=nothing

Next 'I
%>
Thanks.

Brett

Feb 11 '07 #4

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

Similar topics

7
5644
by: Gary | last post by:
I haver a table of students - Say 100 students that I need to be able to update/delete and amend. I know I can do this one student at a time which is simple but lets say I want to see all the...
4
1788
by: dmiller23462 | last post by:
Somebody take a look and give me any suggestions? My brain is nuked... Here's my deal....I have online submission forms on my intranet at work here....I am appending to an Access DB with the...
10
13397
by: Chamomile | last post by:
I have been happily using array members as id's in my html code (either hand coded or generated by server-side script-php ) for some time. eg < input type='text' id='arrayItem' >< input...
6
12744
by: ASPfool | last post by:
Hello everyone, Please help me before I throw my computer out of the window: I'm working on a web application in classic ASP (vbscript), which is making calls to some webservices. The calls...
21
3897
by: Matteo Settenvini | last post by:
Ok, I'm quite a newbie, so this question may appear silly. I'm using g++ 3.3.x. I had been taught that an array isn't a lot different from a pointer (in fact you can use the pointer arithmetics to...
4
1939
by: RFS666 | last post by:
Hello, I have the following problem: I have a web project where I display an activeX control that displays 2D-graphs on an aspx-page. I use jscript to access and modify the properties of the...
7
2927
by: fakeprogress | last post by:
For a homework assignment in my Data Structures/C++ class, I have to create the interface and implementation for a class called Book, create objects within the class, and process transactions that...
1
2667
by: bizt | last post by:
Hi, Im currently looking to move into using JSON for AJAX instead of returning from the server a string like the following: 12345{This is a text string{true I prefer objects because I dont...
5
4051
by: jc | last post by:
Hi. I am in a situation with an engineering application involving monitoring of press operations. This involves storage of numbers for both an X and Y arrays. The number of element within the...
0
7137
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7417
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5659
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5063
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4734
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3210
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
445
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.