Your request has a few issues:
1. The Classic ASP you provided is a function that is being called by a page.
2. The Classis ASP you provided is calling another custom function:
sqlS
So I can only work with what I know, and will be done based on:
1. The .NET equivelant will also be a function, that can be called by the
ActionResult
method.
2. To protect from SQL Injection the method will use
Parameters.
3.
sqlS
is assumed to be some sort of
SQL Sanitatizion
4. The subquery really is not needed.
5. PayID, Rid, and refundID most likely are defined as INT within SQL
6. No need for a "recordset" when only 1 value is being returned.
This will give us something like this
public int getRefundPayId(int refundId, int parentID) {
int RefundPayid = -1;
if (refundId != null) {
string query = "SELECT PayID FROM epayment with (nolock) WHERE ParentPayid = @ParentPayid AND Rid = @Rid";
using (SqlCommand cmd = new SqlCommand(query, my_conn)) {
cmd.Parameters.AddWithValue("@ParentPayid", parentId);
cmd.Parameters.AddWithValue("@Rid", refundId);
RefundPayid = (int)cmd.ExecuteScalar();
}
}
return RefundPayid;
}