EDN Admin
Well-known member
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
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