我是初学者的Windows Mobile 6和IAM试图值传递给数据库,但伊茨不工作,没有错误和警告,请检查我的代码,并帮助我..数据库没有更新..插入数据到数据库中的Windows Mobile 6
private void button1_Click(object sender, EventArgs e)
{
string conSTR = "data source= " +
(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)) +
"\\DPass.sdf; Persist security info=False";
SqlCeConnection connection = new SqlCeConnection(conSTR);
SqlCeCommand cmd = new SqlCeCommand("INSERT INTO cusTable(Fname,Lname) VALUES(@Fname,@Lname)",connection);
cmd.Parameters.AddWithValue("@Fname", textBox1.Text);
cmd.Parameters.AddWithValue("@Lname", textBox2.Text);
connection.Open();
int affectedRows = cmd.ExecuteNonQuery();
cmd.ExecuteNonQuery();
MessageBox.Show("ela");
connection.Close();
}
@ jp2codem我试图在你的方式。有没有错误,但仍然无法执行所有代码最终消息框也来了,但数据库表不更新..帮助我,请非常感谢你 – Nick
我做了一个小的编辑,添加'string.Format(“受影响的行:{ 0}“,affectedRows)'代码到消息框中。如果这返回值为1,那么数据库正在更新。如果你没有看到更新,你可能会检查错误的数据库。 (它发生) – jp2code
yeez你是正确的...数据库正在更新里面emulater .. 非常感谢你帮助我.. :) – Nick