Hello.
Can i insert a record in a table B during reading records in a table A (Sql
Compact Edition 3.1)?
Something like this:
SqlCeConnection c=new SqlCeConnection("Data Source=\test.sdf");
SqleConnection d=new SqlCeConnection("Data Source=\test.sdf");
SqlCeCommand cmd=new SqlCeCommand(c,"SELECT * FROM TABLE A");
SqlCeCommand cmd1=new SqlCeCommand();
cmd1.Connection=d;
cmd.Connection.Open();
cmd1.Connection.Open();
SqlceDataReader dr=cmd.ExecuteReader();
while (dr.read())
{
string a=dr.GetString(0);
string b=dr.GetString(1);
cmd1.Text="INSERT INTO B VALUES('"+a+"','"+b+"')";
cmd1.ExecuteNonQuery();
}
dr.Close();
c.CLose();
d.Close();
Thanks,Simon.
Ginny Caughey MVP - 17 Apr 2008 14:19 GMT
Simone,
You'll need a second SqlCeCommand object for the inserts. You'll also get
better performance if you use a parametized query and just change the
parameters on each insert statement.
Ginny
> Hello.
>
[quoted text clipped - 40 lines]
>
> Thanks,Simon.

Signature
Ginny Caughey
Device Application Development MVP
www.wasteworks.com
Software for Waste Management