Click here to Skip to main content
14,662,660 members
Home » Discussions » ASP.NET
   

ASP.NET

 
Questionreg directive Pin
sowjanya316-Mar-10 22:15
Membersowjanya316-Mar-10 22:15 
AnswerRe: reg directive Pin
Abhijit Jana16-Mar-10 22:34
professionalAbhijit Jana16-Mar-10 22:34 
GeneralRe: reg directive Pin
sowjanya317-Mar-10 0:50
Membersowjanya317-Mar-10 0:50 
QuestionDetailsview - Primary Key - Autogenerate Pin
rikhav16-Mar-10 21:30
Memberrikhav16-Mar-10 21:30 
Question.net webservices tracking usps and ups Pin
laziale16-Mar-10 10:50
Memberlaziale16-Mar-10 10:50 
AnswerRe: .net webservices tracking usps and ups Pin
T M Gray16-Mar-10 11:13
MemberT M Gray16-Mar-10 11:13 
GeneralRe: .net webservices tracking usps and ups Pin
laziale16-Mar-10 11:16
Memberlaziale16-Mar-10 11:16 
QuestionReturn Value from Stored Procedure Pin
ahayw0116-Mar-10 8:06
Memberahayw0116-Mar-10 8:06 
Hello,

I have a asp.net website and a C# web page and I am calling a stored procedure to return the email address of the user that is logged in.

I have debugged my code and am presented with the following error message.

Cannot implicitly convert type 'System.Data.SqlClient.SqlParameter' to 'string'

Any assistance you can provide would be much appreciated.

My code for the web page class and my code for the stored procedure are below.


Thank you,

Allison


EmailTo Class

<br />
public class EmailTo<br />
{<br />
	public string getEmailTo() <br />
	{<br />
     <br />
                // Command - specify as StoredProcedure<br />
                using (System.Data.SqlClient.SqlConnection myConnection = new<br />
                   System.Data.SqlClient.SqlConnection(ConfigurationManager.<br />
                   ConnectionStrings["ConnectionString2"].ConnectionString))<br />
                {<br />
                    System.Data.SqlClient.SqlCommand myCommand2 = new System.Data.SqlClient.SqlCommand();<br />
                    myCommand2.CommandText = "usp_get_email_to";<br />
                    myCommand2.CommandType = CommandType.StoredProcedure;<br />
                    myCommand2.Connection = myConnection;<br />
<br />
                    // Return value as parameter<br />
                    SqlParameter returnEmail = new SqlParameter("Email", SqlDbType.NVarChar);<br />
                    returnEmail.Direction = ParameterDirection.ReturnValue;<br />
                    myCommand2.Parameters.Add(returnEmail);<br />
<br />
<br />
                    // Execute the stored procedure<br />
                    myConnection.Open();<br />
                    myCommand2.ExecuteNonQuery();<br />
                    myConnection.Close();<br />
<br />
                    return returnEmail;<br />
<br />
                                 <br />
            }<br />
        }<br />
}<br />
<br />



Stored Procedure

<br />
CREATE PROCEDURE dbo.usp_get_email_to<br />
<br />
	@Email nvarchar(256),<br />
	@UserId uniqueidentifier<br />
	<br />
AS<br />
<br />
SET @Email  = (SELECT Email FROM aspnet_Membership<br />
	WHERE UserId=@UserId)<br />
<br />
<br />
RETURN @Email<br />
GO<br />
<br />
<br />

AnswerRe: Return Value from Stored Procedure Pin
Sandeep Mewara16-Mar-10 9:14
mentorSandeep Mewara16-Mar-10 9:14 
GeneralRe: Return Value from Stored Procedure Pin
ahayw0116-Mar-10 9:23
Memberahayw0116-Mar-10 9:23 
GeneralRe: Return Value from Stored Procedure Pin
Sandeep Mewara16-Mar-10 9:27
mentorSandeep Mewara16-Mar-10 9:27 
GeneralRe: Return Value from Stored Procedure Pin
Sandeep Mewara16-Mar-10 9:34
mentorSandeep Mewara16-Mar-10 9:34 
GeneralRe: Return Value from Stored Procedure Pin
ahayw0116-Mar-10 9:34
Memberahayw0116-Mar-10 9:34 
GeneralRe: Return Value from Stored Procedure Pin
Sandeep Mewara16-Mar-10 9:38
mentorSandeep Mewara16-Mar-10 9:38 
QuestionDefaulting a DataView control with paging to the last page. Pin
Steven J Jowett16-Mar-10 7:00
MemberSteven J Jowett16-Mar-10 7:00 
AnswerRe: Defaulting a DataView control with paging to the last page. Pin
Sandeep Mewara16-Mar-10 7:15
mentorSandeep Mewara16-Mar-10 7:15 
AnswerRe: Defaulting a DataView control with paging to the last page. Pin
ASHISH GHADI18-Mar-10 22:02
MemberASHISH GHADI18-Mar-10 22:02 
AnswerRe: Defaulting a DataView control with paging to the last page. Pin
ASHISH GHADI18-Mar-10 22:08
MemberASHISH GHADI18-Mar-10 22:08 
Questionif statement in the html code in aspx page Pin
laziale16-Mar-10 5:39
Memberlaziale16-Mar-10 5:39 
AnswerRe: if statement in the html code in aspx page Pin
JHizzle16-Mar-10 5:41
MemberJHizzle16-Mar-10 5:41 
GeneralRe: if statement in the html code in aspx page Pin
laziale16-Mar-10 5:43
Memberlaziale16-Mar-10 5:43 
GeneralRe: if statement in the html code in aspx page Pin
JHizzle16-Mar-10 5:50
MemberJHizzle16-Mar-10 5:50 
AnswerRe: if statement in the html code in aspx page Pin
Sandeep Mewara16-Mar-10 5:44
mentorSandeep Mewara16-Mar-10 5:44 
GeneralRe: if statement in the html code in aspx page Pin
laziale16-Mar-10 5:50
Memberlaziale16-Mar-10 5:50 
AnswerRe: if statement in the html code in aspx page Pin
Sandeep Mewara16-Mar-10 5:51
mentorSandeep Mewara16-Mar-10 5:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.