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
kamal dhillon
NA
23
13.8k
why i cant store values in database but my code and procedure anybody help me am in trouble ?????
Oct 1 2012 2:26 PM
why i cant store values in database but my code is correct when i executing my program that time it showing th value but when i open database that time there is no value shown in database pls somebody help me ??????????????
my stored procedure is
ALTER PROCEDURE registrtn
(
@empname varchar(150),
@desgination varchar(150),
@emailid varchar(150),
@phone varchar(150),
@skype varchar(150),
@address varchar(150),
@shifttime varchar(150),
@panel varchar(150)
)
As
begin
INSERT INTO registrationn VALUES(@empname,@desgination,@emailid,@phone,@skype,@address,@shifttime,@panel)
select SCOPE_IDENTITY() as empid
end
my c# code is
private void button1_submit_Click(object sender, EventArgs e)
{
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
//using (SqlCommand cmdd = new SqlCommand(query , cono))
using ( SqlCommand cmdd = new SqlCommand("registrtn", conn))
{
cmdd.CommandType = CommandType.StoredProcedure;
cmdd.Connection = conn;
// cmdd.Parameters.Add("@empid", SqlDbType.VarChar, 150).Value = textBox7_empid.Text;
cmdd.Parameters.Add("@empname", SqlDbType.VarChar, 150).Value = textBox6_name.Text;
cmdd.Parameters.Add("@desgination", SqlDbType.VarChar,150).Value = textBox5_desgination.Text;
cmdd.Parameters.Add("@emailid", SqlDbType.VarChar, 150).Value = textBox4_emailid.Text;
cmdd.Parameters.Add("@phone", SqlDbType.VarChar, 150).Value = textBox3_phoneno.Text;
cmdd.Parameters.Add("@skype", SqlDbType.VarChar, 150).Value = textBox1_skpid.Text;
cmdd.Parameters.Add("@address", SqlDbType.VarChar, 150).Value = textBox1_add.Text;
cmdd.Parameters.Add("@shifttime", SqlDbType.VarChar, 150).Value = comboBox1_shifttime.Text.ToString();
cmdd.Parameters.Add("@panel", SqlDbType.VarChar, 150).Value = radioButton1_employe.Checked;
SqlParameter p1 = new SqlParameter("@ret", SqlDbType.VarChar,150 );
p1.Direction = ParameterDirection.ReturnValue;
try
{
conn.Open();
cmdd.ExecuteScalar();
conn.Close();
}
catch (Exception ex)
{
Console.WriteLine("Error ", ex);
}
conn.Close();
MessageBox.Show("user successfully added");
Reset();
}
}
Reply
Answers (
1
)
I am going to have Microsoft certif exam on net framework windows forms development .I need your advises as professionals.Thanks
Scroll Bar