[firebase-br] Firebird X Insert com loop
Marcelo Moreira
marcelomoreira.souza em gmail.com
Seg Fev 21 16:24:25 -03 2011
Armando,
No caso estou o Visual Studio sim. Repare que as linhas do arquivo TXT que
eu citei estao contidas no meu objeto recipientDetailList que é onde esta
ocorrendo o loop.
Veja um pedaço do codigo:
FbCommand FbCommandRecipientList = new FbCommand();
this.firebirdConnection.Open();
FbTransaction fbTransaction =
this.firebirdConnection.FbConnection.BeginTransaction();
StringBuilder sbSql = new StringBuilder();
sbSql.Append("INSERT INTO SEND_LIST (PRIORITY_ID, SEND_DATE, SEND_TIME, ");
sbSql.Append("MOBILE_NUMBER, MESSAGE_ALPHA, USERNAME, GROUP_SEND_ID, ");
sbSql.Append("RECIPIENT_CODE, RECIPIENT_NAME, RECIPIENT_RETURN_PHONE, ");
sbSql.Append("RECIPIENT_RETURN_TIME, ACCOUNT_ID, RECIPIENT_PARAMETERS) ");
sbSql.Append("VALUES (@PRIORITY_ID, @SEND_DATE, @SEND_TIME, @MOBILE_NUMBER,
");
sbSql.Append("@MESSAGE_ALPHA, @USERNAME, @GROUP_SEND_ID, @RECIPIENT_CODE,
");
sbSql.Append("@RECIPIENT_NAME, @RECIPIENT_RETURN_PHONE,
@RECIPIENT_RETURN_TIME, ");
sbSql.Append("@ACCOUNT_ID, @RECIPIENT_PARAMETERS)");
FbCommandRecipientList.Connection = this.firebirdConnection.FbConnection;
FbCommandRecipientList.Transaction = fbTransaction;
FbCommandRecipientList.CommandType = CommandType.Text;
FbCommandRecipientList.CommandText = sbSql.ToString();
try
{
foreach (RecipientDetail recipientDetail in recipientDetailList)
{
FbCommandRecipientList.Parameters.Clear();
FbCommandRecipientList.Parameters.Add("PRIORITY_ID", 2);
FbCommandRecipientList.Parameters.Add("SEND_DATE", this.sendDate);
FbCommandRecipientList.Parameters.Add("SEND_TIME", sendTime);
FbCommandRecipientList.Parameters.Add("MOBILE_NUMBER",
recipientDetail.MobileNumber);
FbCommandRecipientList.Parameters.Add("MESSAGE_ALPHA",
recipientDetail.MessageAlpha);
FbCommandRecipientList.Parameters.Add("USERNAME", this.userName);
FbCommandRecipientList.Parameters.Add("GROUP_SEND_ID",
this.groupSendId);
FbCommandRecipientList.Parameters.Add("RECIPIENT_CODE",
recipientDetail.Code);
FbCommandRecipientList.Parameters.Add("RECIPIENT_NAME",
recipientDetail.Name);
FbCommandRecipientList.Parameters.Add("RECIPIENT_RETURN_PHONE",
recipientDetail.ReturnPhone);
FbCommandRecipientList.Parameters.Add("RECIPIENT_RETURN_TIME",
recipientDetail.ReturnTime);
FbCommandRecipientList.Parameters.Add("ACCOUNT_ID", this.accountId);
FbCommandRecipientList.Parameters.Add("RECIPIENT_PARAMETERS",
recipientDetail.RecipientText);
sendTime = sendTime.AddSeconds(recipientInterval);
FbCommandRecipientList.ExecuteNonQuery();
}
}
catch
{
fbTransaction.Rollback;
}
finally
{
fbTransaction.Commit;
}
Mais detalhes sobre a lista de discussão lista