Re: Insert during Select
- From: "Ginny Caughey MVP" <ginny.caughey.online@xxxxxxxxxxxxxx>
- Date: Thu, 17 Apr 2008 09:19:13 -0400
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
"Simone" <simondj1@xxxxxxxxx> wrote in message news:eZc516HoIHA.5836@xxxxxxxxxxxxxxxxxxxxxxx
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
Device Application Development MVP
www.wasteworks.com
Software for Waste Management
.
- References:
- Insert during Select
- From: Simone
- Insert during Select
- Prev by Date: Re: Could not load sqlcecompact30.dll
- Next by Date: Re: SQL Compact 3.1 corrupt database with password
- Previous by thread: Insert during Select
- Index(es):
Loading