We have this C# code that will update SQL server database table based on flags in a structure.
public struct stSRK
{
public string Sno;
public string SClaimID;
public bool SType;
public string SText;
}
Data in the structure can go upto 5000-10000 records at a time.Currently we are using the following C# code to update the database and it makes 'n' number of database calls based on the struct. Would help there is an alternative to do a bulk update using the same struct . Please see the method below
public int UpdateClaims(List<stSRK> _lt, string strClaimType)
{
try
{
int iCount = 0;
for (int i = 0; i < _lt.Count; i++)
{
if (_lt[i].sType == true)
{
if (_lt[i].SText == 'A')
{
iCount += Convert.ToInt16(SQL.ExecuteSQL("UPDATE table SET ClaimType = '" + strClaimType + "' WHERE
(Sno = '" + _lt[i].Sno + "' AND ClaimID = '" + _lt[i].SClaimID + "')"));
}
else
{
iCount += Convert.ToInt16(SQL.ExecuteSQL("UPDATE table SET ClaimType = '" + strClaimType + "' WHERE
(Sno = '" + _lt[i].Sno + "' AND ClaimID = '" + _lt[i].SClaimID + "')"));
}
}
else
{
if (_lt[i].SText == 'B')
{
iCount += Convert.ToInt16(SQL.ExecuteSQL("UPDATE table SET ClaimType = '" + strClaimType + "' WHERE
(Sno = '" + _lt[i].Sno + "' AND ClaimID = '" + _lt[i].SClaimID + "')"));
}
else
{
iCount += Convert.ToInt16(SQL.ExecuteSQL("UPDATE table SET ClaimType = '" + strClaimType + "' WHERE
(Sno = '" + _lt[i].Sno + "' AND ClaimID = '" + _lt[i].SClaimID + "')"));
}
}
return iCount;
}
catch (Exception e)
{
throw e.Message;
}