TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
vutharadi prathyusha
NA
18
26.6k
Must declare the scalar variable
Aug 11 2015 3:04 AM
I am creating a table in stored procedure.For one parameter using bit datatype.
In c# i'am getting error like this
An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code
Additional information: Must declare the scalar variable "@Name@Email".
Code looks like this
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=WALLERO-D-001;Initial Catalog=moyogift;Integrated Security=True");
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "Execute sp_contributors_insert @MagazineId,@Name@Email,@Guid,@ContentSubmitted,@CreatedOn";
cmd.Parameters.Add("@MagazineId", TextBox2.Text);
cmd.Parameters.Add("@Name", TextBox3.Text);
cmd.Parameters.Add("@Email", TextBox4.Text);
cmd.Parameters.Add("@Guid", TextBox5.Text);
SqlParameter param = new SqlParameter();
param.ParameterName = "@ContentSubmitted";
param.DbType = System.Data.DbType.Boolean;
cmd.Parameters.Add(param);
cmd.Parameters.Add("@CreatedOn", TextBox7.Text);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
And my Stored Procedure like this:
USE [moyogift]
GO
/****** Object: StoredProcedure [dbo].[sp_contributors_insert] Script Date: 8/11/2015 11:42:08 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[sp_contributors_insert]
@MagazineId int,
@Name varchar(50),
@Email varchar(100),
@Guid varchar(50),
@ContentSubmitted bit,
@CreatedOn datetime
AS
BEGIN
SET NOCOUNT ON;
insert into Contributors (MagazineId,Name,Email,"Guid",ContentSubmitted,CreatedOn)
values(@MagazineId,@Name,@Email,@Guid,@ContentSubmitted,@CreatedOn)
END
GO
Please tell me suggestions what i'am doing wrong...
Reply
Answers (
2
)
An unhandled exception
Deligates and Event