Insert Issue

R

Rachel

I need to insert some form values into a database, I am
able to do so using a custom query in the DRW in
Frontpage ( 2002 ). ( Where form is page1.asp sending
results to page2.asp which actually does the insert )
But what I really want to do ( for additional
flexibility ) is to do the insert myself with asp code.
However, when I do so I recieve the SQL Server Error 8152
'String or Binary data will be truncated' . If I take
my values and insert them via the Query Analizer, it
works.
I have the same problem with two different insert
statements, so I don't believe it to be specific to the
statement itself. But, if I knew the answer, I wouldn't
be posting this.

My Insert code looks like this:

<%
Set objDC = Server.CreateObject("ADODB.Connection")
objDC.Open Application("Ads_ConnectionString")

Set objRS = objDC.Execute("INSERT INTO CustomerInfo
(LastName, FirstName, CustomerID, Address1, Phone1, Zip,
City, State) VALUES
('::LastName::', '::FirstName::', '::Email::', '::Address
::', '::phone::', '::Zip::', '::City::', '::State::')")
%>
<%
' Close Data Access Objects and free DB variables
objRS.Close
Set objRS = Nothing
objDC.Close
Set objDC = Nothing
%>


Any Ideas??
Thanks so much!!
 
M

MD WebsUnlimited.com

Hi Rachel,

The error is normally associated with the design of the database field sizes
and the size of the data fields being sent in. Have you checked that the
sizes are correct?
 
R

Rachel

Yes, I had checked that over and over. What my ( and
this is embarassing ) problem was that I was using the
same code as what frontpage generates ( the ::fieldname::
sytax ) rather than creating a correct sql insert
statement. So it was trying to insert '::state::' into a
2 character state field.
Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top