reisende76
Programmer
- Mar 18, 2008
- 3
Hello all,
I am attempting to migrate some old code we have from VB 6 to C# using Visual Studio 2008 and I am looking for the best practice solution for my quandry. Here's what I've got.
In the VB 6 code we run a query and populate a data array using GetRows. We then check the array using IsArray(arTemp). If that is false we immediately run a second query with additional WHERE clause criteria and redefine the arTemp array. This isn't a problem in VB 6 as it's just an array with no messy open DataSets or anything else to deal with.
Here's an example:
I am curious as to how you guys would approach this in C# .Net. Can I do something similar using DataSet or DataReader? I've been cooking up some work arounds but they all seem to be more involved than is probably needed.
Thanks in advance,
Tony
I am attempting to migrate some old code we have from VB 6 to C# using Visual Studio 2008 and I am looking for the best practice solution for my quandry. Here's what I've got.
In the VB 6 code we run a query and populate a data array using GetRows. We then check the array using IsArray(arTemp). If that is false we immediately run a second query with additional WHERE clause criteria and redefine the arTemp array. This isn't a problem in VB 6 as it's just an array with no messy open DataSets or anything else to deal with.
Here's an example:
Code:
sqlString = "SELECT FirstName, LastName FROM Employees WHERE ExternalID = " & vExternalID
arTemp = getRcds(sqlString)
If IsArray(arTemp)
'Employee is found
Else
sqlString = "SELECT FirstName, LastName FROM Employees WHERE Email = '" & vEmail & "'"
arTemp = getRcds(sqlString)
If IsArray(arTemp)
'Employee is found
Else
'Employee not found. Return error.
End If
End If
I am curious as to how you guys would approach this in C# .Net. Can I do something similar using DataSet or DataReader? I've been cooking up some work arounds but they all seem to be more involved than is probably needed.
Thanks in advance,
Tony