Click here to Skip to main content
15,860,972 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Data Reader only producing one row of records. Any ideas why? Pin
Richard Deeming3-May-19 3:29
mveRichard Deeming3-May-19 3:29 
GeneralRe: Data Reader only producing one row of records. Any ideas why? Pin
samflex3-May-19 3:51
samflex3-May-19 3:51 
GeneralRe: Data Reader only producing one row of records. Any ideas why? Pin
Richard Deeming3-May-19 5:27
mveRichard Deeming3-May-19 5:27 
GeneralRe: Data Reader only producing one row of records. Any ideas why? Pin
samflex3-May-19 7:06
samflex3-May-19 7:06 
AnswerRe: Data Reader only producing one row of records. Any ideas why? Pin
jkirkerx3-May-19 9:18
professionaljkirkerx3-May-19 9:18 
GeneralRe: Data Reader only producing one row of records. Any ideas why? Pin
samflex3-May-19 9:51
samflex3-May-19 9:51 
GeneralRe: Data Reader only producing one row of records. Any ideas why? Pin
jkirkerx3-May-19 10:16
professionaljkirkerx3-May-19 10:16 
GeneralRe: Data Reader only producing one row of records. Any ideas why? Pin
jkirkerx3-May-19 10:34
professionaljkirkerx3-May-19 10:34 
I didn't like your database code.
Your code seemed really labor intensive. Maybe that's why Richard suggested binding.
Here's a sample to give you an idea of how you can condense and shorten your code. This code has been Jet Brains Ultimate Refactored to be as small as possible. You can feed as many parameters you want. This passes a model into the function, and returns another model as the result.

You just need to change the connection type and string and parameter type for whatever db server technology your using.
Private Shared Function Get_FI_Customer_SAInvoices(
    ByVal sFi As FreeInvoice) As List(Of InvoiceIndex)

            Dim pResults As New List(Of InvoiceIndex)
            Dim dbPath = RegistryShared.Read_HKCU_DataPath()
            Dim connString As String = "Provider=" & My.Resources.DBProviderOLE & "; Data Source=" & dbPath & "; Extended Properties=dBASE IV"
            Const queryString As String =
    "SELECT " &
    " h.FINVNO " &
    "FROM ARADD01H.dbf h" &
    " WHERE h.FCOMPANY = @FCOMPANY " &
    " AND h.FCITY = @FCITY " &
    " AND h.FZIP = @FZIP " &
    "UNION ALL " &
    "SELECT " &
    " v.FINVNO " &
    "FROM ARADD01.dbf v" &
    " WHERE v.FCOMPANY = @FCOMPANY " &
    " AND v.FCITY = @FCITY " &
    " AND v.FZIP = @FZIP "

            Using connection As New OleDbConnection(connString)
                Using command As New OleDbCommand(queryString, connection)

                    command.Parameters.Add(New OleDbParameter("@FCOMPANY", OleDbType.VarChar)).Value = sFi.FCUSTOMER_NAME
                    command.Parameters.Add(New OleDbParameter("@FCITY", OleDbType.VarChar)).Value = sFi.FADDRESS.City
                    command.Parameters.Add(New OleDbParameter("@FZIP", OleDbType.VarChar)).Value = sFi.FADDRESS.PostalCode

                    Try

                        connection.Open()
                        Using reader As OleDbDataReader = command.ExecuteReader()
                            While reader.Read()

                                If Not reader.IsDBNull(0) Then

                                    pResults.Add(New InvoiceIndex() With {
                                .InvoiceNumber = reader.GetValue(0),
                                .InvoiceDate = DateTime.Now
                            })

                                End If

                            End While

                            reader.Close()
                        End Using

                    Catch ex As Exception
                        ErrorLogging.NLog_Exception(ex, "Db_FI_CustomerAdvByDate")

                    Finally

                        connection.Close()

                    End Try

                End Using
            End Using

            Return pResults

        End Function
If it ain't broke don't fix it
Discover my world at jkirkerx.com

GeneralRe: Data Reader only producing one row of records. Any ideas why? Pin
samflex10-May-19 4:39
samflex10-May-19 4:39 
GeneralRe: Data Reader only producing one row of records. Any ideas why? Pin
jkirkerx10-May-19 8:22
professionaljkirkerx10-May-19 8:22 
GeneralRe: Data Reader only producing one row of records. Any ideas why? Pin
samflex10-May-19 10:31
samflex10-May-19 10:31 
GeneralRe: Data Reader only producing one row of records. Any ideas why? Pin
jkirkerx12-May-19 13:15
professionaljkirkerx12-May-19 13:15 
GeneralRe: Data Reader only producing one row of records. Any ideas why? Pin
samflex16-May-19 14:39
samflex16-May-19 14:39 
Questionodata Pin
Member 140736591-May-19 2:33
Member 140736591-May-19 2:33 
AnswerRe: odata Pin
jkirkerx3-May-19 9:01
professionaljkirkerx3-May-19 9:01 
QuestionSOAP and using a Class containing two sub classes with same name problem Pin
Martin Stevens26-Apr-19 17:18
Martin Stevens26-Apr-19 17:18 
AnswerRe: SOAP and using a Class containing two sub classes with same name problem Pin
jkirkerx3-May-19 8:38
professionaljkirkerx3-May-19 8:38 
GeneralRe: SOAP and using a Class containing two sub classes with same name problem Pin
Martin Stevens10-May-19 20:03
Martin Stevens10-May-19 20:03 
GeneralRe: SOAP and using a Class containing two sub classes with same name problem Pin
jkirkerx12-May-19 13:03
professionaljkirkerx12-May-19 13:03 
Questionprint sql data from vb Pin
Member 1433060825-Apr-19 1:17
Member 1433060825-Apr-19 1:17 
AnswerRe: print sql data from vb Pin
Afzaal Ahmad Zeeshan25-Apr-19 1:36
professionalAfzaal Ahmad Zeeshan25-Apr-19 1:36 
QuestionSharing API's between multiple sites in IIS 8.5 Pin
Fred283424-Apr-19 21:39
Fred283424-Apr-19 21:39 
AnswerRe: Sharing API's between multiple sites in IIS 8.5 Pin
Richard Deeming25-Apr-19 1:17
mveRichard Deeming25-Apr-19 1:17 
GeneralRe: Sharing API's between multiple sites in IIS 8.5 Pin
Fred283425-Apr-19 1:47
Fred283425-Apr-19 1:47 
QuestionSo I finally got my Angular wrapped in .Net Core 2.2 app working in a Docker Container on a production server. Pin
jkirkerx16-Apr-19 11:14
professionaljkirkerx16-Apr-19 11:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.