Click here to Skip to main content
15,888,202 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Coding Horror of the Millennium in a banking application Pin
Vasudevan Deepak Kumar28-Sep-07 4:08
Vasudevan Deepak Kumar28-Sep-07 4:08 
GeneralRe: Coding Horror of the Millennium in a banking application Pin
destynova5-Oct-07 2:32
destynova5-Oct-07 2:32 
GeneralRe: Coding Horror of the Millennium in a banking application Pin
Rajesh R Subramanian2-Oct-07 23:07
professionalRajesh R Subramanian2-Oct-07 23:07 
GeneralAnother from my boss! Pin
Burnsys224-Sep-07 6:17
Burnsys224-Sep-07 6:17 
GeneralRe: Another from my boss! Pin
Chris Meech24-Sep-07 7:31
Chris Meech24-Sep-07 7:31 
GeneralAnd more! Pin
Burnsys224-Sep-07 8:08
Burnsys224-Sep-07 8:08 
GeneralRe: And more! Pin
hogan31-Oct-07 6:07
hogan31-Oct-07 6:07 
GeneralAnother one Pin
Burnsys224-Sep-07 8:21
Burnsys224-Sep-07 8:21 
This was done to read a file like this (That he designed also):

1 CONNECT=PROVIDER=SQLOLEDB.1;driver={SQL Server}
2 server=BGHLOCALES
3 uid=sa
4 pwd=408603222608533
5 database=LCR
6 Connect timeout=30
7 CommandTimeout=550



On Error GoTo h_err_con

    If tIdd = -1 Then
'Conect a SS
        i = 0
        tmp = App.Path + "\Bases.ini"
        If Dir(tmp) = "" Then
            MensajeBOX "Error en configuración. Falta archivo: " & tmp, vbCritical, "Control de entorno"
            Exit Function
        Else
            strConnect = ""
            Open tmp For Input As #1
            Do While Not EOF(1)
                Line Input #1, tmp
                
                If i = 0 Then
                    tmpPos = InStrRev(tmp, "1 CONNECT")
                    If tmpPos > 0 Then
                        strConnect = Trim(Mid(tmp, tmpPos + 10)) & ";"
                        i = 1
                    End If
                Else
                    If i = 1 Then
                        tmpPos = InStrRev(tmp, "2 server")
                        If tmpPos > 0 Then
                            strConnect = strConnect & Trim(Mid(tmp, tmpPos + 2)) & ";"
                            i = 2
                        End If
                    Else
                        If i = 2 Then
                            tmpPos = InStrRev(tmp, "3 uid")
                            If tmpPos > 0 Then
                                strConnect = strConnect & Trim(Mid(tmp, tmpPos + 2)) & ";"
                                i = 3
                            End If
                        Else
                            If i = 3 Then
                                tmpPos = InStrRev(tmp, "4 pwd")
                                If tmpPos > 0 Then
'                                    tmpCr = CodificarLI("XVB2S45AF", 1)
'                                    tmpCr = DeCodificarLI(tmpCr, 1)
                                    tmpCr = DeCodificarLI(Trim(Mid(tmp, tmpPos + 6)))
                                    strConnect = strConnect & "pwd=" & tmpCr & ";"
                                    i = 4
                                End If
                            Else
                                If i = 4 Then
                                    tmpPos = InStrRev(tmp, "5 database")
                                    If tmpPos > 0 Then
                                        strConnect = strConnect & Trim(Mid(tmp, tmpPos + 2)) & ";"
                                        i = 5
                                    End If
                                Else
                                    If i = 5 Then
                                        tmpPos = InStrRev(tmp, "6 ")
                                        If tmpPos > 0 Then
                                            strConnect = strConnect & Trim(Mid(tmp, tmpPos + 2)) & ";"
                                            i = 6
                                        End If
                                    Else
                                        If i = 6 Then
                                            tmpPos = InStrRev(tmp, "7 ")
                                            If tmpPos > 0 Then
                                                strConnect = strConnect & Trim(Mid(tmp, tmpPos + 2)) & ";"
                                                i = 7
                                            End If
                                        Else
                                            If i = 7 Then
                                                tmpPos = InStrRev(tmp, "8 ")
                                                If tmpPos > 0 Then
                                                    strConnect = strConnect & Trim(Mid(tmp, tmpPos + 2)) & ";"
                                                    i = 8
                                                End If
                                            Else
                                            
                                            End If
                                        End If
                                    End If
                                End If
                            End If
                        End If
                    End If
                End If
            Loop
            Close #1
            If strConnect = "" Then
                MensajeBOX "Error en configuración. Error en archivo: " & "Bases.ini", vbCritical, "Control de entorno"
                Exit Function
            End If
        End If

        Set db = New ADODB.Connection
        db.ConnectionTimeout = 30
        db.CursorLocation = adUseClient
        db.Open strConnect


And of course, this piece of code was used in every aplication that used a conection with a sql server.
GeneralRe: Another one Pin
Dan Neely24-Sep-07 8:30
Dan Neely24-Sep-07 8:30 
GeneralRe: Another one Pin
Burnsys224-Sep-07 8:43
Burnsys224-Sep-07 8:43 
GeneralRe: Another one Pin
Pete O'Hanlon24-Sep-07 9:42
mvePete O'Hanlon24-Sep-07 9:42 
GeneralRe: Another one Pin
blackjack215024-Sep-07 22:34
blackjack215024-Sep-07 22:34 
GeneralRe: Another one Pin
Michael Sync2-Oct-07 21:36
Michael Sync2-Oct-07 21:36 
GeneralRe: Another one Pin
Pete O'Hanlon3-Oct-07 9:48
mvePete O'Hanlon3-Oct-07 9:48 
GeneralRe: Another one Pin
SimonRigby26-Sep-07 22:37
SimonRigby26-Sep-07 22:37 
GeneralRe: Another one Pin
Russell Jones27-Sep-07 2:39
Russell Jones27-Sep-07 2:39 
GeneralRe: Another one Pin
Burnsys227-Sep-07 3:29
Burnsys227-Sep-07 3:29 
GeneralRe: Another one Pin
blackjack215024-Sep-07 22:36
blackjack215024-Sep-07 22:36 
GeneralRe: Another one Pin
Pete O'Hanlon24-Sep-07 23:12
mvePete O'Hanlon24-Sep-07 23:12 
GeneralRe: Another one Pin
Burnsys225-Sep-07 2:35
Burnsys225-Sep-07 2:35 
GeneralRe: Another one Pin
Steve Hansen26-Sep-07 23:17
Steve Hansen26-Sep-07 23:17 
GeneralRe: Another one Pin
Burnsys227-Sep-07 1:42
Burnsys227-Sep-07 1:42 
GeneralGive your boss a break, man Pin
Xiangyang Liu 刘向阳24-Sep-07 23:13
Xiangyang Liu 刘向阳24-Sep-07 23:13 
GeneralRe: Give your boss a break, man [modified] Pin
Burnsys225-Sep-07 2:26
Burnsys225-Sep-07 2:26 
GeneralRe: Give your boss a break, man Pin
leppie25-Sep-07 4:12
leppie25-Sep-07 4:12 

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.