0
我試圖在單個事務中插入巨大的多行。但是SQL Server數據庫沒有被更新反映出來。以下是我的代碼片段。我究竟做錯了什麼?SQL Server CE插入/更新多行
private void Form1_Load(object sender, EventArgs e)
{
string conString = Properties.Settings.Default.Database1ConnectionString;
Database1DataSet.Table1DataTable dt = new Database1DataSet.Table1DataTable();
for (int i = 0; i < 5; i++)
{
dt.AddTable1Row(i.ToString(), "name" + i.ToString());
}
// Open the connection using the connection string.
using (SqlCeConnection con = new SqlCeConnection(conString))
{
try
{
var cmd = con.CreateCommand();
con.Open();
cmd.CommandType = CommandType.TableDirect;
cmd.CommandText = "Table1";
var rs = cmd.ExecuteResultSet(ResultSetOptions.Updatable)
var rec = rs.CreateRecord();
foreach (DataRow dr in dt.Rows)
{
rec.SetString(0, dr["ID"].ToString());
rec.SetString(1, dr["Name"].ToString());
rs.Insert(rec);
}
rs.Close();
rs.Dispose();
cmd.Dispose();
}
catch (Exception ex) { }
}
}
建議您登錄任何異常,而不是忽視他們... – 2012-01-31 06:14:32
嗨米奇,我沒有得到任何的異常。 – mlg 2012-01-31 06:30:34
在包含數據的數據庫中查找bin/debug文件夾? – ErikEJ 2012-01-31 07:22:01