0

I am reworking old VB6 apps into VB.NET with Visual Studio 2005 and all of them suffer from the same problems.

One of those is, access the DB2 database by using an Access 2000 file which has links to the tables and second approach is, using ADODB.RecordSet with concatenated string SQL queries directly run on to the database.

I know I can use Linq which is the right tool for the job, but I don't have time to learn it at the moment. I have to finish this job quickly.

Examples:

Function selectNA_FromMyTable_ByNA(ByVal na As String) As String
    Dim sql As String = "SELECT na FROM DB2Scheme.MyTable "
    sql = sql & "WHERE (na = '" & na & "')"

    Return sql
End Function

and

Function selectNA_FromMyTable_ByNA(ByVal na As String) As String
    Dim sql As String = "SELECT na FROM DB2Scheme_MyTable "
    sql = sql & "WHERE (na = '" & na & "')"

    Return sql
End Function

where DB2Scheme_MyTable is link to DB2Scheme.MyTable table.

I don't like mixing approaches although they both work properly.

Which is better approach?

Which approach would be better for debugging? For example, how can I detect that the user using the application does not have privileges to write or read data from a certain table in the scheme?

Vlad
  • 2,591
  • 4
  • 43
  • 88
  • 2
    Seems highly opinion driven but a few things: VS2005 limits you to NET 2.0 which does not include linq. It also seems like ADONET would be an important upgrade – Ňɏssa Pøngjǣrdenlarp Nov 27 '17 at 14:57
  • 1
    Don't use ADODB.RecordSet in .net if you can (and you can) avoid it. – IvanH Nov 29 '17 at 14:06
  • I will try @IvanH :) the people here are very old-fashioned. New, better technologies are hard to implement – Vlad Nov 29 '17 at 14:10

1 Answers1

1

well certainly eliminating the Access database would be ideal. i assume in the prior model, the Access database also served as the front-end? if you're moving to .net, then i don't see the point in keeping the access database. go directly to the db2 database, just be mindful of the database drivers that may need to be installed when distributing this app. less of a problem if its a web app.

generic error handling in .net should reveal if users have access issues. you may want to check that up front when your application is launched if your application is going to use the users credentials, and not a user id of its own to access the database. I am not sure this should be something of a concern when rewriting the app, are you not using the same authentication, or logon credentials used in the formal app?

O. Gungor
  • 718
  • 5
  • 8