Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an error here when i try to view emails by by date in my database here is the function and stored procedure
VB
#Region "View sent email by date"
    Public Function view_sent_email(ByVal [date] As Date) As DataTable
        Dim list As New List(Of csParameterList)
        Dim dal As New csSQLDALVB
        list.Add(New csParameterList("@e_send_date", SqlDbType.VarChar, [date].ToString()))
        Return dal.executespreturndt("view_sent_email_by_date", list)
    End Function
#End Region

SQL
ALTER proc [dbo].[view_sent_email_by_date](
@e_sent_date datetime)
as
if exists(select email_sender,email_subject,email_body,e_sent_date,EMAIL_SENT_TO from sent_Email
                where convert(varchar(30),e_sent_date,106) = convert(varchar(30),@e_sent_date,106))
		begin
			select  email_sender as 'Email Sender',email_subject as 'Subject',EMAIL_SENT_TO as 'Message Destination Email',email_body as 'Email Body',e_sent_date as 'Message Sent Time'from sent_Email
                  where convert(varchar(30),e_sent_date,106) =  convert(varchar(30),@e_sent_date,106)
		end;
else
begin
select'1'as'no sent email'
end;

The error says
Procedure or function'view_email_by_date', expects parameter'@e_sent_date', which was not passed.


The date I am searching which is not null.
Posted
Updated 8-Oct-11 13:15pm
v2

1 solution

There is a naming conflict in the parameter you are passing

1. Your VB applicaiton passes
@e_send_date
but your stored procedure expects
@e_sent_date
and there is a difference in the letter "send" (VB) compared to the SP "sent"

Change the line
list.Add(New csParameterList("@e_send_date", SqlDbType.VarChar, [date].ToString()))
to
list.Add(New csParameterList("@e_sent_date", SqlDbType.VarChar, [date].ToString()))
and it should work.
 
Share this answer
 
v2
Comments
Mehdi Gholam 9-Oct-11 1:35am    
my 5!
Bala Selvanayagam 9-Oct-11 2:53am    
Thanks Mehdi
simtho 9-Oct-11 12:16pm    
Thank you very much!. now can you help me with the code to under button to save data in an array

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900