Solved

string or binary data would be truncated

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

757 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