Not able to insert data into sdf database

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,
I am trying to insert records into sdf file which is at the root. But Nothing is get inserted neither any error.
Here is my code:
<pre class="prettyprint SqlCeConnection conn = new SqlCeConnection();
conn.ConnectionString = "Data Source = Database1.sdf";

conn.Open();

SqlCeCommand cmd = new SqlCeCommand();
cmd.Connection = conn;

SqlCeDataAdapter sda = new SqlCeDataAdapter();

cmd.CommandText = "INSERT INTO WFATable (name, id) VALUES (@name, @id)";
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@Name", textBox1.Text);
cmd.Parameters.AddWithValue("@id", textBox2.Text);
sda.InsertCommand = cmd;
cmd.ExecuteNonQuery();
conn.Close();
MessageBox.Show("OK");[/code]
Please help me.
Thanks in advance

View the full article
 
Back
Top