Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
O

Ondrej Linhart

@Ondrej Linhart
About
Posts
3
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Epic method to check if database table contains any suitable rows
    O Ondrej Linhart

    It is true that i did not optimized SQL command, only removed worst trash from code. It is hundreds of records at maximum and it is not over network - only locally using SQL Server Compact Edition.

    The Weird and The Wonderful database

  • Epic method to check if database table contains any suitable rows
    O Ondrej Linhart

    In this case it is something like "marking". Stupid naming in former developer's native language is next horrifying issue.

    The Weird and The Wonderful database

  • Epic method to check if database table contains any suitable rows
    O Ondrej Linhart

    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:

    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

    The Weird and The Wonderful database
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups