473,770 Members | 1,787 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

string Truncated error

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(strin g)
if string = "" then string = " "
ChkString = Replace(string, "'", "''")
End Function

set my_conn= Server.CreateOb ject("ADODB.Con nection")
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_D ate") &
"'"
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_d ate") & "', '" & chkString(reque st("txt")) & "')"
else ' Record found. i.e. update record.
StrSql = "UPDATE diary SET diary.dte = '" & request("view_d ate") & "',
text_field = '" & chkString(reque st("txt")) & "' WHERE id = " &
rs("id")
End If

my_conn.Execute (strSql)

'''''''''''

thanks
chumley

Jul 22 '05 #1
3 1653
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*******@yaho o.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.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(strin g)
if string = "" then string = " "
ChkString = Replace(string, "'", "''")
End Function

set my_conn= Server.CreateOb ject("ADODB.Con nection")
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_D ate") &
"'"
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_d ate") & "', '" & chkString(reque st("txt")) & "')"
else ' Record found. i.e. update record.
StrSql = "UPDATE diary SET diary.dte = '" & request("view_d ate") & "',
text_field = '" & chkString(reque st("txt")) & "' WHERE id = " &
rs("id")
End If

my_conn.Execute (strSql)

'''''''''''

thanks
chumley

Jul 22 '05 #2
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_d ate") & "', '" & chkString(reque st("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.
Jul 22 '05 #3
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(strin g)
if string = "" then string = " "
ChkString = Replace(string, "'", "''")
End Function

set my_conn= Server.CreateOb ject("ADODB.Con nection")
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_D ate") &
"'"
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_d ate") & "', '" & chkString(reque st("txt")) & "')"
else ' Record found. i.e. update record.
StrSql = "UPDATE diary SET diary.dte = '" & request("view_d ate") & "',
text_field = '" & chkString(reque st("txt")) & "' WHERE id = " &
rs("id")
End If

my_conn.Execute (strSql)

'''''''''''

thanks
chumley

Jul 22 '05 #4

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

Similar topics

6
10780
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"
3
3390
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 field has got much larger than when the code was developed all those years ago. This is always very hard to debug and I'd really like SQL Server to throw an error when this happens. I don't feel confident enablying the full ANSI_WARNINGS as it...
3
40182
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 but I can't get it to tell me which records are causing the error. Here's the script I'm running: EXEC sp_executesql N'UPDATE IMDISFIL_SQL
7
10629
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 namespace std; : : vector<string>* getTyphoon()
1
3707
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 database, but noticed that in the process it truncated a few large text blocks. I then plugged the ColdFusion web application into the PG database and ran into problems trying to insert large text blocks into the database. Error as follows:
1
2813
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, TriState.False, TriState.True, TriState.True) ctotal is a char column in an sql server table; total is a currency column in the same table. Notwithstanding, the conversion appears to be made, even though the exception is being thrown. Any help would be...
7
43932
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 object. 4. If string size is less than the size of the rectangle, we are done.
7
17712
Coldfire
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" MaxLength="1000" /></asp:TextBox> and this textbox is in a <asp:Repeater > which has the count of 35. The textbox value is stored in the SQL DB And the field data-type in the SQL DB is VARCHAR(1000)
15
5214
geolemon
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 execute the SQL code. Here's the corresponding snippets: 'declare variables: Dim strProc As String
0
9617
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
9454
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
10257
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
10099
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9904
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
5354
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
4007
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
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
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.