G
Guest
Hi all,
I've a database composed from one field as primary key (smallint) and second
field (NVarChar,20).
I try to insert 1000 record with this code and run correctly. Why if I try
to insert 10000 record the program fails ?
string insertSql = "INSERT INTO Impianti" + "(Codice, Nome) VALUES (@Codice,
@Nome)";
SqlCeConnection cn = new SqlCeConnection(@"Data Source =""\Hard
Disk\Database\MioDatabase.sdf"";");
cn.Open();
int recordsAffected = 0;
try
{
for (int i = 0; i < 1000; i++)
{
SqlCeCommand cmd = new SqlCeCommand(insertSql, cn);
cmd.Parameters.Add(new System.Data.SqlServerCe.SqlCeParameter("@Codice",
System.Data.SqlDbType.SmallInt, 2));
cmd.Parameters["@Codice"].Value = i + 1;
cmd.Parameters.Add(new System.Data.SqlServerCe.SqlCeParameter("@Nome",
System.Data.SqlDbType.NVarChar, 20));
cmd.Parameters["@Nome"].Value = (i + 1).ToString();
recordsAffected = cmd.ExecuteNonQuery();
}
}
catch
{
}
finally
{
cn.Close();
}
I've a database composed from one field as primary key (smallint) and second
field (NVarChar,20).
I try to insert 1000 record with this code and run correctly. Why if I try
to insert 10000 record the program fails ?
string insertSql = "INSERT INTO Impianti" + "(Codice, Nome) VALUES (@Codice,
@Nome)";
SqlCeConnection cn = new SqlCeConnection(@"Data Source =""\Hard
Disk\Database\MioDatabase.sdf"";");
cn.Open();
int recordsAffected = 0;
try
{
for (int i = 0; i < 1000; i++)
{
SqlCeCommand cmd = new SqlCeCommand(insertSql, cn);
cmd.Parameters.Add(new System.Data.SqlServerCe.SqlCeParameter("@Codice",
System.Data.SqlDbType.SmallInt, 2));
cmd.Parameters["@Codice"].Value = i + 1;
cmd.Parameters.Add(new System.Data.SqlServerCe.SqlCeParameter("@Nome",
System.Data.SqlDbType.NVarChar, 20));
cmd.Parameters["@Nome"].Value = (i + 1).ToString();
recordsAffected = cmd.ExecuteNonQuery();
}
}
catch
{
}
finally
{
cn.Close();
}