Click here to Skip to main content
15,884,099 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.

 
JokeRe: Perfect way to show a splash screen Pin
micmanos22-Nov-11 12:37
micmanos22-Nov-11 12:37 
GeneralDocument layout Pin
TorstenH.16-Nov-11 2:49
TorstenH.16-Nov-11 2:49 
GeneralRe: Document layout Pin
BillW3317-Nov-11 6:11
professionalBillW3317-Nov-11 6:11 
GeneralNot so much bad code as kludge Pin
Dalek Dave11-Nov-11 13:52
professionalDalek Dave11-Nov-11 13:52 
GeneralRe: Not so much bad code as kludge Pin
Reiss13-Nov-11 22:55
professionalReiss13-Nov-11 22:55 
GeneralRe: Not so much bad code as kludge Pin
Dalek Dave13-Nov-11 22:59
professionalDalek Dave13-Nov-11 22:59 
GeneralRe: Not so much bad code as kludge Pin
Member 256047216-Nov-11 3:50
Member 256047216-Nov-11 3:50 
GeneralEpic method to check if database table contains any suitable rows Pin
Ondřej Linhart9-Nov-11 3:24
Ondřej Linhart9-Nov-11 3:24 
VB
Public Function CHeckDataPrjVyd(ByVal data As String) As Boolean
    Dim cn As System.Data.SqlServerCe.SqlCeConnection
    Dim cmd As System.Data.SqlServerCe.SqlCeCommand
    Dim dtr As System.Data.SqlServerCe.SqlCeDataReader
    Dim i As Integer = 0

    cn = New System.Data.SqlServerCe.SqlCeConnection("Data Source=" + values.DatabaseFile)
    cn.Open()
    cmd = New System.Data.SqlServerCe.SqlCeCommand("SELECT * FROM data where oznacenie like '" + data + "'", cn)
    dtr = cmd.ExecuteReader()

    While dtr.Read
        i = i + 1
        If i = 1 Then
            CHeckDataPrjVyd = True
            Exit While
        End If
        CHeckDataPrjVyd = False
    End While
    cn.Close()
End Function

After cleaning that monstrosity:
VB
Public Function IsDataPresent(ByVal data As String) As Boolean
  Using connection As New SqlCeConnection(My.Settings.ConnectionString)
    connection.Open()
    Dim commandText = String.Format("SELECT * FROM data WHERE oznacenie LIKE '{0}'", data)
    Using command As New SqlCeCommand(commandText, connection)
      Using reader = command.ExecuteReader()
        Return reader.HasRows
      End Using
    End Using
  End Using
End Function


modified 9-Nov-11 9:38am.

GeneralRe: Epic method to check if database table contains any suitable rows Pin
Wayne Gaylard9-Nov-11 3:54
professionalWayne Gaylard9-Nov-11 3:54 
GeneralRe: Epic method to check if database table contains any suitable rows Pin
BobJanova10-Nov-11 6:01
BobJanova10-Nov-11 6:01 
GeneralRe: Epic method to check if database table contains any suitable rows PinPopular
Nagy Vilmos9-Nov-11 3:58
professionalNagy Vilmos9-Nov-11 3:58 
GeneralRe: Epic method to check if database table contains any suitable rows Pin
CDP18029-Nov-11 4:31
CDP18029-Nov-11 4:31 
GeneralRe: Epic method to check if database table contains any suitable rows Pin
Ondřej Linhart9-Nov-11 6:57
Ondřej Linhart9-Nov-11 6:57 
GeneralRe: Epic method to check if database table contains any suitable rows Pin
BobJanova10-Nov-11 6:03
BobJanova10-Nov-11 6:03 
GeneralRe: Epic method to check if database table contains any suitable rows Pin
AspDotNetDev10-Nov-11 6:40
protectorAspDotNetDev10-Nov-11 6:40 
GeneralRe: Epic method to check if database table contains any suitable rows Pin
BobJanova10-Nov-11 23:21
BobJanova10-Nov-11 23:21 
GeneralRe: Epic method to check if database table contains any suitable rows Pin
AspDotNetDev11-Nov-11 6:35
protectorAspDotNetDev11-Nov-11 6:35 
GeneralRe: Epic method to check if database table contains any suitable rows Pin
RobCroll10-Nov-11 23:56
RobCroll10-Nov-11 23:56 
GeneralRe: Epic method to check if database table contains any suitable rows Pin
Ondřej Linhart11-Nov-11 5:41
Ondřej Linhart11-Nov-11 5:41 
GeneralRe: Epic method to check if database table contains any suitable rows Pin
James H1-Dec-11 2:33
James H1-Dec-11 2:33 
GeneralRe: Epic method to check if database table contains any suitable rows Pin
Mel Padden16-Nov-11 10:00
Mel Padden16-Nov-11 10:00 
GeneralRe: Epic method to check if database table contains any suitable rows Pin
prasun.r23-Nov-11 3:10
prasun.r23-Nov-11 3:10 
GeneralThis is pretty special. PinPopular
Mel Padden3-Nov-11 7:30
Mel Padden3-Nov-11 7:30 
GeneralRe: This is pretty special. PinPopular
QuiJohn3-Nov-11 8:01
QuiJohn3-Nov-11 8:01 
GeneralRe: This is pretty special. Pin
Mel Padden3-Nov-11 9:17
Mel Padden3-Nov-11 9:17 

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.