Having trouble with proper syntax for sql update statement.

  • (2 Pages)
  • +
  • 1
  • 2

19 Replies - 1070 Views - Last Post: 14 January 2013 - 04:05 PM Rate Topic: -----

#16 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3720
  • View blog
  • Posts: 13,007
  • Joined: 12-December 12

Re: Having trouble with proper syntax for sql update statement.

Posted 11 January 2013 - 04:46 PM

I would prefer to prepend 'p' to distinguish between the table and parameter-names, but that's just the way I am :)
Was This Post Helpful? 0
  • +
  • -

#17 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5627
  • View blog
  • Posts: 12,070
  • Joined: 02-June 10

Re: Having trouble with proper syntax for sql update statement.

Posted 11 January 2013 - 04:55 PM

View Postandrewsw, on 11 January 2013 - 05:37 PM, said:

But shouldn't TableEmail, etc., be properties of an object,


They are. They are properties of the PreferencesObj class and get loaded when the application launches. I wouldn't want to have to recompile an application because the DB manager changed the column names. Its much easier to edit the Preferences file the application is reading. The example above is simplistic and just shows the default name, which gets changed when the preferences load.
Was This Post Helpful? 0
  • +
  • -

#18 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3720
  • View blog
  • Posts: 13,007
  • Joined: 12-December 12

Re: Having trouble with proper syntax for sql update statement.

Posted 11 January 2013 - 05:05 PM

Don't let anyone change the table names :gun_bandana: :surrender:
Was This Post Helpful? 0
  • +
  • -

#19 billy_welsh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 04-December 12

Re: Having trouble with proper syntax for sql update statement.

Posted 14 January 2013 - 03:56 PM

Is there a a better way of passing null values to parameters?

                If DateTimePicker1.Checked = False Then
                    .Parameters.AddWithValue("@value1", DBNull.Value)
                Else
                    .Parameters.AddWithValue("@value1", DateTimePicker1.Text)
                End If


Was This Post Helpful? 0
  • +
  • -

#20 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3720
  • View blog
  • Posts: 13,007
  • Joined: 12-December 12

Re: Having trouble with proper syntax for sql update statement.

Posted 14 January 2013 - 04:05 PM

A slight variation is

    .Parameters.AddwithValue("@value1",
        If(DateTimePicker1.Checked, DateTimePicker1.Text, DBNull.Value))


I don't know if there is a better way.

We can nest With statements as well, but this won't help :)/>

This post has been edited by andrewsw: 14 January 2013 - 04:12 PM

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2