Click here to Skip to main content
15,918,685 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: it's possible....... Pin
Dave Kreskowiak26-May-04 4:22
mveDave Kreskowiak26-May-04 4:22 
Generalhelp running project Pin
GaryKoh25-May-04 17:13
GaryKoh25-May-04 17:13 
GeneralRe: help running project Pin
Nick Seng25-May-04 18:45
Nick Seng25-May-04 18:45 
GeneralRe: help running project Pin
GaryKoh25-May-04 19:25
GaryKoh25-May-04 19:25 
GeneralRe: help running project Pin
Nick Seng25-May-04 19:48
Nick Seng25-May-04 19:48 
GeneralRe: help running project Pin
ps1k027-May-04 2:35
ps1k027-May-04 2:35 
QuestionHow can I use string SQL to search or compare DateTime correctly? Pin
ATC25-May-04 17:04
ATC25-May-04 17:04 
AnswerRe: How can I use string SQL to search or compare DateTime correctly? Pin
Dave Kreskowiak25-May-04 17:45
mveDave Kreskowiak25-May-04 17:45 
Your first, and last, mistake is using a concantenated string for an SQL statement.

ALWAYS, ALWAYS, ALWAYS, ... continue for 10 more minutes ..., ALWAYS use PARAMETERIZED queries!

Using a parameterized query will automatically make sure that the date is translated into the appropriate format for the SQL statement. Also, the reverse is true. Any date that is returned will be converted back to the appropriate format for your code.

This is an example from a project I am working on:
            Try
                oConnection = GetDatabaseConnection()
                oCommand = New SqlCommand
 
                oCommand.Connection = oConnection
                oCommand.CommandText = "SecurityValidateLogin"
                oCommand.CommandType = CommandType.StoredProcedure
 
                Dim sqlParam As New SqlParameter("@Username", SqlDbType.NVarChar, 50)
                sqlParam.Value = sUserName
                oCommand.Parameters.Add(sqlParam)
 
                sqlParam = New SqlParameter("@Password", SqlDbType.NVarChar, 15)
                sqlParam.Value = sPassword
                oCommand.Parameters.Add(sqlParam)
 
                sqlParam = New SqlParameter("@SourceIP", SqlDbType.NVarChar, 32)
                sqlParam.Value = sSourceIP
                oCommand.Parameters.Add(sqlParam)
 
                oConnection.Open()
                oCommand.ExecuteNonQuery()
                oConnection.Close()
 
                ' code removed
 
            Catch ex As Exception
                LogErrorEvent("SecurityServices", "ValidateUserLogin", ex.Message, ex.StackTrace)
                Throw ex
            Finally
                ' Trash our open objects
                If Not oCommand Is Nothing Then
                    oCommand.Dispose()
                End If
                If Not oConnection Is Nothing Then
                    If Not oConnection.State = ConnectionState.Closed Then
                        oConnection.Close()
                    End If
                    oConnection.Dispose()
                End If
            End Try
 
            Return retValidateValue


RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome

GeneralRe: How can I use string SQL to search or compare DateTime correctly? Pin
Charlie Williams25-May-04 18:12
Charlie Williams25-May-04 18:12 
GeneralRe: How can I use string SQL to search or compare DateTime correctly? Pin
Dave Kreskowiak26-May-04 0:32
mveDave Kreskowiak26-May-04 0:32 
GeneralRe: How can I use string SQL to search or compare DateTime correctly? Pin
ATC26-May-04 11:15
ATC26-May-04 11:15 
GeneralRe: How can I use string SQL to search or compare DateTime correctly? Pin
Dave Kreskowiak26-May-04 16:22
mveDave Kreskowiak26-May-04 16:22 
GeneralAny one knows the better way to connecting to Oracle DB. Pin
jlizardo25-May-04 10:39
jlizardo25-May-04 10:39 
GeneralRe: Any one knows the better way to connecting to Oracle DB. Pin
Dave Kreskowiak25-May-04 11:36
mveDave Kreskowiak25-May-04 11:36 
QuestionHow do I perform a 2's Complement Sum in VB.Net Pin
DudleyDoorite25-May-04 9:54
DudleyDoorite25-May-04 9:54 
Generaltrying to hide certain columns in a datagrid Pin
kowplunk25-May-04 7:56
kowplunk25-May-04 7:56 
GeneralRe: trying to hide certain columns in a datagrid Pin
Nick Seng25-May-04 15:45
Nick Seng25-May-04 15:45 
GeneralRe: trying to hide certain columns in a datagrid Pin
kowplunk26-May-04 4:21
kowplunk26-May-04 4:21 
GeneralRe: trying to hide certain columns in a datagrid Pin
Nick Seng26-May-04 15:19
Nick Seng26-May-04 15:19 
GeneralConverting MS Access Data Type Pin
MicSky25-May-04 4:20
MicSky25-May-04 4:20 
GeneralRe: Converting MS Access Data Type Pin
mikasa25-May-04 4:22
mikasa25-May-04 4:22 
QuestionDeploying a VB.Net application with third party dlls? Pin
palei25-May-04 1:31
palei25-May-04 1:31 
AnswerRe: Deploying a VB.Net application with third party dlls? Pin
Sarvesvara (BVKS) Dasa26-May-04 7:37
Sarvesvara (BVKS) Dasa26-May-04 7:37 
GeneralUsercontrols on Panes Pin
emari25-May-04 1:00
emari25-May-04 1:00 
GeneralRe: Usercontrols on Panes Pin
Dave Kreskowiak25-May-04 2:09
mveDave Kreskowiak25-May-04 2:09 

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.