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
Umesh Daiya
NA
21
1.1k
unique value store in database using store procedture in ASP
Apr 10 2020 6:34 AM
create
table
tbl_user (
userID
int
Primary
Key
identity (1,1),
userName
varchar
(20),
pass
varchar
(30),
email
varchar
(50),
userRole
int
,
userPhoto
varchar
(100),
userStatus
int
,
);
//my store
procedure
is
create
PROCEDURE
spCreateUser
@userName
varchar
(20),
@pass
varchar
(30),
@email
varchar
(50),
@userRole
int
,
@userPhoto
varchar
(100),
@userStatus
int
,
@result
int
output
AS
BEGIN
IF EXISTS(
SELECT
*
FROM
tbl_user
WHERE
userName= @userName)
SET
@result = 1
ELSE
BEGIN
SET
@result = 0
INSERT
INTO
tbl_user(userName,pass,email,userRole,userPhoto,userStatus)
VALUES
(@userName,@pass,@email,@userRole,@userPhoto,@userStatus)
END
return
@result
END
protected
void
btn_insert_Click(
object
sender, EventArgs e)
{
string
CS = ConfigurationManager.ConnectionStrings[
"DBCS"
].ConnectionString;
string
path =
string
.Concat(Server.MapPath(
"~/UploadFile/"
+ fu_photo.FileName));
fu_photo.SaveAs(path);
using
(SqlConnection con =
new
SqlConnection(CS))
{
SqlCommand cmd =
new
SqlCommand(
"spCreateUser"
, con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue(
"userName"
, txt_username.Text);
cmd.Parameters.AddWithValue(
"pass"
, txt_pass.Text);
cmd.Parameters.AddWithValue(
"email"
, txt_email.Text);
cmd.Parameters.AddWithValue(
"userRole"
, ddl_role.SelectedValue);
cmd.Parameters.AddWithValue(
"userPhoto"
, path);
cmd.Parameters.AddWithValue(
"userStatus"
, ddl_status.SelectedValue);
con.Open();
int
k = cmd.ExecuteNonQuery();
if
(k != 0)
{
lblMsg.Text =
"Record Inserted Succesfully into the Database"
;
lblMsg.ForeColor = System.Drawing.Color.CornflowerBlue;
}
con.Close();
}
}
code not workig properly plz tell me what is missed by me.
Thanks & Regards
Reply
Answers (
1
)
unable to send array data using ajax with asp.net core
Hide any div tag from page source or inspect