Solved

string or binary data would be truncated

Posted on 2006-11-13
3
725 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

726 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