well i have do make a application that remove, update and add
information in sql tables i have this but i can´t add. can help me
please?
i have this --> http://www.freeimagehosting.net/uploads/e115ce2713.jpg
thanks
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Vijaya KadiyalaRank #1,085 · 1.8K reputationPosted Feb 26, 2009, 8:16 AM EST
Hi
You need to use ExecuteNonQuery.
If your command is Insert, Update or Delete, executeNonquery returns an integer specifying the number of rows affected.
Thanks -- Vijaya Kadiyala
lovely neha44 reputationPosted Feb 25, 2009, 1:44 AM EST
hii..
hi ...instead of DataAdapter..use ExcecuteNonQuery...
Cmd.ExecuteNonQuery();
connection.close();
Raul10 reputationPosted Feb 26, 2009, 9:35 AM EST
string connectionPath = "Data Source=.\\SQLEXPRESS;AttachDbFilename=" + Directory.GetCurrentDirectory()+ "\\Teste.mdf" +";Integrated Security=True; Connect Timeout=30;User Instance=True";
SqlConnection sc = new SqlConnection(connectionPath);
sc.Open();
SqlCommand cmd = new SqlCommand("INSERT INTO student VALUES( '" + this.textBox1.Text + "','" + this.textBox2.Text + "','" + this.textBox3.Text + "','" + this.textBox4.Text + "')",sc);
int temp = cmd.ExecuteNonQuery();
if (temp > 0)
{
MessageBox.Show("Record Added");
}
else
{
MessageBox.Show("Record not Added");
}
mycon.Close();
Vijaya KadiyalaRank #1,085 · 1.8K reputationPosted Feb 27, 2009, 10:46 AM EST
Hi
i am glad to see that you got the answer. Keep visiting C# Corner to improve your knowledge.
Thanks -- Vijaya Kadiyala