Store data in database table in sqlserver from microsoft visual studio

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Maryam M
    New Member
    • Jun 2011
    • 1

    Store data in database table in sqlserver from microsoft visual studio

    hi
    i want to store data in table in my database in sqlserver from microsoft visual studio, but i can not, because give error Incorrect syntax near 'valuse' and it point to co.ExecuteNonQu ery(); please help to me.
    my code:
    Code:
            private void btn_add_person_Click(object sender, EventArgs e)
            {
                SqlConnection cmd = new SqlConnection(@"data source = (local);integrated security = sspi;initial catalog = db_library");
                
                string input = "@ insert into person(name,family,father_name,id,email,job,birth_certificate,superscription,phone_number,national_issue) valuse (" + "'" + txt_name.Text + "','" + txt_family.Text + "','" + txt_father_name.Text + "'," + Convert.ToInt32(txt_id.Text) + ",'" + txt_email.Text + "','" + txt_job.Text + "'," + Convert.ToInt32(txt_birth_certificate.Text) + ",'" + txt_superscription.Text + "'," + Convert.ToInt32(txt_phone_number.Text) + "," + Convert.ToInt32(txt_national_issue.Text) + ")";
                SqlCommand co = new SqlCommand(input,cmd);
                cmd.Open();
                co.ExecuteNonQuery();
                cmd.Close();
            
            }
    Last edited by Niheel; Jun 11 '11, 11:34 AM.
  • Subin Ninan
    New Member
    • Sep 2010
    • 91

    #2
    Spelling mistake, change valuse to values and command is not well formed. Check syntax of command string (" ' "+ txtname.Text... ........

    Comment

    Working...