I'm getting a "string could be truncated" error at the line where my
strSql is executed ( my_conn.Execute (strSql) ), but it doesnt happen
all the time, just periodically. I used to have this pointing to an
Access db, but I changed it over to Sql, getting rid of the # datetime
delimiters and replacing with ' . Wondering if the first StrSql string
in the if statement if too long:
'''''''''''''''''''''''''''
Function ChkString(string)
if string = "" then string = " "
ChkString = Replace(string, "'", "''")
End Function
set my_conn= Server.CreateObject("ADODB.Connection")
my_Conn.Open DBCon
' Check to see if it's a new record to be added or an old one to
update
StrSql= "Select * from diary where dte = '" & Request("view_Date") &
"'"
set rs = my_conn.Execute (StrSql)
if rs.BOF or rs.EOF then ' No records found. i.e. New record
StrSql ="INSERT INTO diary (dte, text_field) values ('" &
request("view_date") & "', '" & chkString(request("txt")) & "')"
else ' Record found. i.e. update record.
StrSql = "UPDATE diary SET diary.dte = '" & request("view_date") & "',
text_field = '" & chkString(request("txt")) & "' WHERE id = " &
rs("id")
End If
my_conn.Execute (strSql)
'''''''''''
thanks
chumley 3 1643
Well, what is the table definition (e.g. datatype and length of
"text_field" - which is an awful, awful name for a column, by the way)?
--
Please post DDL, sample data and desired results.
See http://www.aspfaq.com/5006 for info.
"Chumley Walrus" <sp*******@yahoo.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com... I'm getting a "string could be truncated" error at the line where my strSql is executed ( my_conn.Execute (strSql) ), but it doesnt happen all the time, just periodically. I used to have this pointing to an Access db, but I changed it over to Sql, getting rid of the # datetime delimiters and replacing with ' . Wondering if the first StrSql string in the if statement if too long:
''''''''''''''''''''''''''' Function ChkString(string) if string = "" then string = " " ChkString = Replace(string, "'", "''") End Function
set my_conn= Server.CreateObject("ADODB.Connection") my_Conn.Open DBCon
' Check to see if it's a new record to be added or an old one to update StrSql= "Select * from diary where dte = '" & Request("view_Date") & "'" set rs = my_conn.Execute (StrSql)
if rs.BOF or rs.EOF then ' No records found. i.e. New record StrSql ="INSERT INTO diary (dte, text_field) values ('" & request("view_date") & "', '" & chkString(request("txt")) & "')" else ' Record found. i.e. update record. StrSql = "UPDATE diary SET diary.dte = '" & request("view_date") & "', text_field = '" & chkString(request("txt")) & "' WHERE id = " & rs("id") End If
my_conn.Execute (strSql)
'''''''''''
thanks chumley
Chumley Walrus wrote: I'm getting a "string could be truncated" error at the line where my strSql is executed ( my_conn.Execute (strSql) ), but it doesnt happen all the time, just periodically...
Are you using POST or GET for your form method? Using request("txt") is
ambiguous.
...StrSql ="INSERT INTO diary (dte, text_field) values ('" & request("view_date") & "', '" & chkString(request("txt"))...
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Hi,
This error happens when the data that you try to update or insert in the
table is more than what the field can handle. For ex: a varchar(20) string
cannot hold more than 20 characters. So you will get the error when you pass
a string to this field which is more than 20.
Ganesh
"Chumley Walrus" wrote: I'm getting a "string could be truncated" error at the line where my strSql is executed ( my_conn.Execute (strSql) ), but it doesnt happen all the time, just periodically. I used to have this pointing to an Access db, but I changed it over to Sql, getting rid of the # datetime delimiters and replacing with ' . Wondering if the first StrSql string in the if statement if too long:
''''''''''''''''''''''''''' Function ChkString(string) if string = "" then string = " " ChkString = Replace(string, "'", "''") End Function
set my_conn= Server.CreateObject("ADODB.Connection") my_Conn.Open DBCon
' Check to see if it's a new record to be added or an old one to update StrSql= "Select * from diary where dte = '" & Request("view_Date") & "'" set rs = my_conn.Execute (StrSql)
if rs.BOF or rs.EOF then ' No records found. i.e. New record StrSql ="INSERT INTO diary (dte, text_field) values ('" & request("view_date") & "', '" & chkString(request("txt")) & "')" else ' Record found. i.e. update record. StrSql = "UPDATE diary SET diary.dte = '" & request("view_date") & "', text_field = '" & chkString(request("txt")) & "' WHERE id = " & rs("id") End If
my_conn.Execute (strSql)
'''''''''''
thanks chumley
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Gaurav |
last post by:
Hello,
I am using visual c++ 6 and i am having problems with string to work.
******** Here is the program project.cpp*********
#include <iostream.h>
#include <string>
#include "stdafx.h"
|
by: David Sharp |
last post by:
I'm working with some long standing VB/SQL Server applications and for
the second time we've suffered from having the parameters to a stored
procedure call get silently truncated now that the data...
|
by: RDRaider |
last post by:
How can I find which record(s) cause this error:
Server: Msg 8152, Level 16, State 9, Line 1
String or binary data would be truncated.
The statement has been terminated.
I have tried Profiler...
|
by: Forecast |
last post by:
I run the following code in UNIX compiled by g++ 3.3.2 successfully.
: // proj2.cc: returns a dynamic vector and prints out at main~~
: //
: #include <iostream>
: #include <vector>
:
: using...
|
by: Dino Nardini |
last post by:
Hey folks,
I've been migrating a content management system from MS SQL Server 7 over
to PostgreSQL. I used the EMS DataPump utility
(http://www.ems-hitech.com/index.phtml) to migrate the...
| |
by: Bernie Yaeger |
last post by:
What causes the error 'string or binary data would be truncated'? Here's
the routine that sometimes causes the error, sometimes not:
irow("ctotal") = FormatCurrency(irow("total"), 2,...
|
by: carterweb |
last post by:
This is how I do it now.
1. Determine the dimensions of the rectangle.
2. Set a my font size to a fixed maximum size.
3. Apply the font my string and measure the string using the graphics...
|
by: Coldfire |
last post by:
i am having error ....details are
ASP.Net application...in which I have a textbox
<asp:TextBox ID="Other" TextMode=SingleLine CssClass="serviceBox" Width="250" Height="45" Runat="server"...
|
by: geolemon |
last post by:
I'm having a seriously Twilight Zone moment:
In the code below, I'm building a SQL command into a string variable, declared at the top of my code.
Then, I connect to the database and try to...
|
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,...
|
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...
| |
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,...
|
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...
|
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,...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |