Home Forums Programming Powershell Inserting into table with Powershell RE: Inserting into table with Powershell

  • Del Lee (12/6/2012)


    Thanks for all the replies. ..

    Thank you for the feedback !

    Keep in mind you will - sooner or later - hit localization problems because you convert stuff to its string format.

    e.g. $date = get-date

    To what format is it being translated in your $cmd.commandtext ?

    Well, you aren't formatting it yourself, so the result is depedent on the local user settings of the computer your script is being run on !

    There is a simple cure: Take control!

    $date = get-date -format 'yyyy-MM-dd HH:mm.ss.fff'

    Same goes with decimal point vs comma

    There is also a solution where you build your query as a parameterized query and pass the values to be stored as parameters. This way you also avoid SQLInjection issues ! :w00t:

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me