473,804 Members | 2,292 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.c om
em****@domain.c om
em****@domain.c om
em****@domain.c om

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="VB SCRIPT" 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.CreateOb ject("ADODB.Con nection")
Conn.Open "driver={SQ L Server};server= aaaaaaa;"
SQLStmt = "INSERT INTO tbl_advertisers (email_address) "
SQLStmt = SQLStmt & "VALUES ('" & varArray(I) & "')"
Set RS = Conn.Execute(SQ LStmt)
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.cou nt0 then
response.write "Database Errors Occured" & "<P>"
response.write SQLstmt & "<P>"
for counter= 0 to conn.errors.cou nt
response.write "Error #" & conn.errors(cou nter).number & "<P>"
response.write "Error desc. -" & conn.errors(cou nter).descripti on &
"<P>"
next
else
end if
Conn.Close
set conn=nothing

Next 'I
%>
Thanks.

Brett

Feb 1 '07 #1
3 3897

"Brett_A" <br********@gma il.comwrote in message
news:11******** **************@ l53g2000cwa.goo glegroups.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.c om
em****@domain.c om
em****@domain.c om
em****@domain.c om

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="VB SCRIPT" 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.CreateOb ject("ADODB.Con nection")
Conn.Open "driver={SQ L Server};server= aaaaaaa;"
SQLStmt = "INSERT INTO tbl_advertisers (email_address) "
SQLStmt = SQLStmt & "VALUES ('" & varArray(I) & "')"
Set RS = Conn.Execute(SQ LStmt)
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.cou nt0 then
response.write "Database Errors Occured" & "<P>"
response.write SQLstmt & "<P>"
for counter= 0 to conn.errors.cou nt
response.write "Error #" & conn.errors(cou nter).number & "<P>"
response.write "Error desc. -" & conn.errors(cou nter).descripti on &
"<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@**REMO VE**THIS**gmail .comwrote:
"Brett_A" <brettat...@gma il.comwrote in message

news:11******** **************@ l53g2000cwa.goo glegroups.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.c om
ema...@domain.c om
ema...@domain.c om
ema...@domain.c om
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="VB SCRIPT" 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.CreateOb ject("ADODB.Con nection")
Conn.Open "driver={SQ L Server};server= aaaaaaa;"
SQLStmt = "INSERT INTO tbl_advertisers (email_address) "
SQLStmt = SQLStmt & "VALUES ('" & varArray(I) & "')"
Set RS = Conn.Execute(SQ LStmt)
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.cou nt0 then
response.write "Database Errors Occured" & "<P>"
response.write SQLstmt & "<P>"
for counter= 0 to conn.errors.cou nt
response.write "Error #" & conn.errors(cou nter).number & "<P>"
response.write "Error desc. -" & conn.errors(cou nter).descripti on &
"<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********@gma il.comwrote in message
news:11******** **************@ l53g2000cwa.goo glegroups.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.c om
em****@domain.c om
em****@domain.c om
em****@domain.c om

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="VB SCRIPT" 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.CreateOb ject("ADODB.Con nection")
Conn.Open "driver={SQ L Server};server= aaaaaaa;"
SQLStmt = "INSERT INTO tbl_advertisers (email_address) "
SQLStmt = SQLStmt & "VALUES ('" & varArray(I) & "')"
Set RS = Conn.Execute(SQ LStmt)
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.cou nt0 then
response.write "Database Errors Occured" & "<P>"
response.write SQLstmt & "<P>"
for counter= 0 to conn.errors.cou nt
response.write "Error #" & conn.errors(cou nter).number & "<P>"
response.write "Error desc. -" & conn.errors(cou nter).descripti on &
"<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
5662
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 students on the screen at the same time, modify some, mark some for deletion and even have blank fields at the end to add a new record. In HTML which is generated I label each row and input field with a name/number combination i.e <input type=text...
4
1801
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 input from all HTML fields and then querying aforementioned DB with different variables (search by name, wave, reason, etc). The output that I'm getting (SELECT * 'cause I need all of the data included in the search) I would like to display in a nice...
10
13453
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 type='text' id='arrayItem' >etc. particlarly in forms for sending input data to be server processed. and also using javascript client-side for dynamic text menu-trees etc. This has worked fine using IE Netscape and Opera as test browsers.
6
12767
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 are made using SOAP - i installed the SOAP3 toolkit on my windows 2k server to enable this. The webservice calls are returning String Arrays which I can't seem to do anything useful with. The call shown below returns a string array with two...
21
3942
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 "browse" it). So I expected that when I run this program, I get both c1.A and c2.A pointing to the same address, and changing c1.A means that also c2.A changes too. ----- BEGIN example CODE -----------
4
1951
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 activeX-2D-control. In codebehind, I use C# for the application logic (eg. the database access). The query to the database retuns me an object of a C# class (called DBResultSet) that contains all the data from the query. This data has then to be...
7
2960
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 manipulate (and report on) members of the class. Interface consists of: - 5 private variables char author; char title; char code;
1
2680
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 need to specifiy the index key and I can treat it exactly like an array - oSet = ... Are objects just as quick to access/alter as arrays? I have a few
5
4076
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 arrays varies slightly but should be identical for a singular press operation. One approach is to store an element in a row. This would be 6000 rows (3000 elements/axis * 2). This seems excessive for a single operation. Also, I have no...
0
9711
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9591
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10594
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10087
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6861
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5529
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.