Solved

string or binary data would be truncated

Posted on 2006-11-13
3
723 Views
Last Modified: 2012-06-22
Hi,
 
   I am working on another source file. i am getting an error in the following method at this line.
 
 
MyAdapter.Fill(EmailList)

Error message:string or binary data would be truncated . The statement has been terminated.


 
Sub EmailNameList()

Dim cmd As New SqlCommand("usp_select_alarm_email_list", Conn)

cmd.CommandType = CommandType.StoredProcedure

Dim AlarmIdParm As SqlParameter = cmd.Parameters.Add("@AlarmId", SqlDbType.Int)

AlarmIdParm.Value = AlarmId

Dim EmailList As DataSet = New DataSet

Dim MyAdapter As New SqlDataAdapter()

MyAdapter.SelectCommand = cmd

MyAdapter.Fill(EmailList)

emailGridView.DataSource = EmailList

emailGridView.DataBind()

End Sub

I can post  the stored procedure as well.Please look in to that , but i can execute the stored procedure.
 
 
 
 
ALTER procedure [dbo].[usp_select_alarm_email_list] (@AlarmId int) as

declare @email_list table

(

email_id int,

description varchar(250),

email_type char(1)

)

insert into @email_list (email_id, description, email_type)

select

email_id, description, 'P'

from

email_address_book

insert into @email_list (email_id, description, email_type)

select

distribution_list_id, description, 'L'

from

distribution_list

select

t.email_id,

t.description,

email_type =

case

when t.email_type = 'L' then 'Distribution'

when t.email_type = 'P' then 'Individual'

else 'Unknown'

end ,

selected =

CASE

WHEN a.id is NULL THEN 0

ELSE 1

END

from

@email_list t

left outer join alarm_email_relation a (NOLOCK)

on t.email_id = a.id and

t.email_type = a.email_type and

a.alarm_id = @AlarmId

 
Thanks,
 
Sreekanth Nagabandi,
0
Comment
Question by:Sreekanth_Nagabandi
3 Comments
 
LVL 10

Accepted Solution

by:
Kinger247 earned 500 total points
ID: 17932441
Looks like your trying to insert data that is to large for the table column.
0
 
LVL 6

Expert Comment

by:riyazthad
ID: 17932451
Its look like you are not returning anything from sp.

put last line as

select * from @email_list
0
 
LVL 10

Expert Comment

by:ibost
ID: 17933010
Look at the base tables:
email_address_book and distribution_list

The problem is in one of those tables, the column for "description" is bigger than varchar(250).

When you declare the table variable here:
declare @email_list table

(

email_id int,

description varchar(250),

email_type char(1)

)

Make sure you allow the "description" column to be at least as big as the biggest "description" column in the base tables.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question