Solved

string or binary data would be truncated

Posted on 2006-11-13
3
722 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

914 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now