I am new to C# and programming in .NET
I am pretty sure this needs some better error handling around the connection at least.
Can anyone suggest improvements to my small code below?
Thank you in advance.
I am pretty sure this needs some better error handling around the connection at least.
Can anyone suggest improvements to my small code below?
Thank you in advance.
Code:
SQLErrors = "";
SqlConnection cn = new SqlConnection(connectionStringGP);
cn.Open();
string sql = "exec tdbTransferWarehouseItemGetDocNo '" + sEmpInitials + "'";
SqlCommand cd = new SqlCommand(sql, cn);
DocNo = "";
bDupDocNo = false;
SqlDataReader dr2 = cd.ExecuteReader();
if (dr2.Read())
{
DocNo = dr2["DocNo"].ToString();
}
dr2.Close();