Professional Web Applications Themes

Command Parameters - ASP.NET General

Can someone tell me why the following code does not work ? It does not crash or cause errors and it creates a new row in the table "tblusers" but the fields are NULL. Sub doInsert() 'Create Insert string Dim MySQL As String = "Insert into tblusers (USERTEXT) values (Pnotes)" 'Set up connection to mysql database Dim myConn As OdbcConnection = New OdbcConnection("driver={MySql};uid=root;pwd=;serve r=127.0.0.1;database=dbnrg plc;OPTION=17923") Dim Cmd As New OdbcCommand(MySQL, myConn) Cmd.Parameters.Add(New OdbcParameter("Pnotes", Me.txtNotes.Text)) myConn.Open() Cmd.ExecuteNonQuery() myConn.Close() End Sub Thanks in Advance...

  1. #1

    Default Command Parameters

    Can someone tell me why the following code does not work ?

    It does not crash or cause errors and it creates a new row in the table
    "tblusers" but the fields are NULL.

    Sub doInsert()
    'Create Insert string
    Dim MySQL As String = "Insert into tblusers (USERTEXT) values (Pnotes)"
    'Set up connection to mysql database
    Dim myConn As OdbcConnection = New
    OdbcConnection("driver={MySql};uid=root;pwd=;serve r=127.0.0.1;database=dbnrg
    plc;OPTION=17923")
    Dim Cmd As New OdbcCommand(MySQL, myConn)
    Cmd.Parameters.Add(New OdbcParameter("Pnotes", Me.txtNotes.Text))
    myConn.Open()
    Cmd.ExecuteNonQuery()
    myConn.Close()
    End Sub

    Thanks in Advance


    Paul Guest

  2. #2

    Default Re: Command Parameters

    Paul,

    Run the debugger and see if the text box actually has a value in it.

    My guess is that your code is clearing the text box on post back.

    Sincerely,

    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:
    [url]www.aboutfortunate.com[/url]

    "Out of chaos comes order."
    Nietzche
    "Paul" <paulthemedialounge.com> wrote in message
    news:udxTRUCXDHA.888TK2MSFTNGP10.phx.gbl...
    > Can someone tell me why the following code does not work ?
    >
    > It does not crash or cause errors and it creates a new row in the table
    > "tblusers" but the fields are NULL.
    >
    > Sub doInsert()
    > 'Create Insert string
    > Dim MySQL As String = "Insert into tblusers (USERTEXT) values
    (Pnotes)"
    > 'Set up connection to mysql database
    > Dim myConn As OdbcConnection = New
    >
    OdbcConnection("driver={MySql};uid=root;pwd=;serve r=127.0.0.1;database=dbnrg
    > plc;OPTION=17923")
    > Dim Cmd As New OdbcCommand(MySQL, myConn)
    > Cmd.Parameters.Add(New OdbcParameter("Pnotes", Me.txtNotes.Text))
    > myConn.Open()
    > Cmd.ExecuteNonQuery()
    > myConn.Close()
    > End Sub
    >
    > Thanks in Advance
    >
    >

    S. Justin Gengo Guest

Similar Threads

  1. get command line parameters in plugin (i.e. argc & argv)
    By davide.gironi@gmail.com in forum Adobe Acrobat SDK
    Replies: 0
    Last Post: May 17th, 01:16 PM
  2. Replies: 1
    Last Post: March 3rd, 02:15 PM
  3. SPs/Command Object/Parameters Problem
    By Chopper in forum ASP Database
    Replies: 4
    Last Post: October 9th, 01:07 PM
  4. Projector with command line parameters
    By Tharion webforumsuser@macromedia.com in forum Macromedia Director Lingo
    Replies: 3
    Last Post: September 11th, 11:35 AM
  5. Passing parameters to a Perl Script from Command Line (Linux)
    By Dave from Dublin in forum PERL Miscellaneous
    Replies: 4
    Last Post: July 23rd, 08:36 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139