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.9k
HOW CAN WE CHECK THE ENTERED VALUE IS GOING SQL SERVER OR NOT ???
Oct 2 2012 5:02 PM
WHY I CANT STORE VALUE IN DATABASE WHEN I EXECUTING MY PROGRAM THAT TIME ITS DISPLAY NO ERROR BUT AFTER INSERTION OF DATA THE DATA CAN NOT STORED IN THE DATABASE SO TELL ME WHY ITS NOT STORED IN THE DATABASE ????
private void ExecuteInsert(string empname,string desgination,string emailid,string phone, string skype ,string address,string shifttime,string panel)
{
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
SqlDataReader rdr = null;
try
{
SqlCommand cmdd = new SqlCommand();
cmdd.CommandText = "INSERT INTO registrationn(empname,desgination,emailid,phone,skype,address,shifttime,panel)" + " VALUES (@empname,@desgination,@emailid,@phone,@skype,@address,@shifttime,@panel)";
cmdd.CommandType = CommandType.Text;
cmdd.Connection = conn;
cmdd.Parameters.Add("@empname", SqlDbType.VarChar , 150).Value = empname ;
cmdd.Parameters.Add("@desgination", SqlDbType.VarChar,150).Value = desgination ;
cmdd.Parameters.Add("@emailid", SqlDbType.VarChar, 150).Value = emailid ;
cmdd.Parameters.Add("@phone", SqlDbType.Int ).Value = Convert.ToString (phone) ;
cmdd.Parameters.Add("@skype", SqlDbType.VarChar, 150).Value =skype ;
cmdd.Parameters.Add("@address", SqlDbType.VarChar, 150).Value = address ;
cmdd.Parameters.Add("@shifttime", SqlDbType.VarChar, 150).Value = shifttime ;
cmdd.Parameters.Add("@panel", SqlDbType.VarChar, 150).Value = panel ;
SqlParameter p1 = new SqlParameter("@ret", SqlDbType.VarChar, 150);
p1.Direction = ParameterDirection.ReturnValue;
cmdd.ExecuteNonQuery ();
rdr = cmdd.ExecuteReader();
int jh;
int.TryParse(p1.Value.ToString(), out jh);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
conn.Close();
}
}
private void button1_submit_Click(object sender, EventArgs e)
{
if (radioButton1_employe.Checked == true)
{
ExecuteInsert(textBox6_name.Text , textBox5_desgination.Text, textBox4_emailid.Text, textBox3_phoneno.Text, textBox1_skpid.Text, textBox1_add.Text, comboBox1_shifttime.SelectedItem.ToString(), radioButton1_employe.Checked.ToString());
}
else
{
MessageBox.Show("data not stored ");
}
}
Reply
Answers (
2
)
Number Pair
c#,sql