Close

Results 1 to 13 of 13
  1. #1
    Inactive
    Detector's Avatar
    Join Date
    Jun 2001
    Location
    Grim North
    Posts
    7,483
    Thanks
    2,587
    Thanked:        2,712
    Karma Level
    1040

    PC need help with some code for visual basic - asap if you can lads ------

    basically im wanting to make an app to connect remotely to my database on my server.
    ive got the app connecting fine and it writes into the first field fine but I want to write in 2 fields at once.
    for exampke
    field 1 may be username
    field 2 will be password.

    the app im designing lets the user manually add people to the database but ive got it working adding field 1 but am stuck trying to get it writing to both fields here is the code im using, any help appreciated.

    Private
    Sub cmdSave_Click(sender AsObject, e AsEventArgs) Handles cmdSave.Click

    Dim SQLStatement AsString = "Insert INTO user(username) VALUES('" & txtName.Text & "')"
    savenames(SQLStatement)

    EndSub
    A wise man once said " "

  2. #2
    VIP Member CzarJunkie's Avatar
    Join Date
    Jun 2001
    Location
    Atlantis
    Posts
    13,754
    Thanks
    832
    Thanked:        3,225
    Karma Level
    1991

    Default Re: need help with some code for visual basic - asap if you can lads ------

    INSERT INTO [tablename] ( [column1], [column2], ... ) VALUES ( [value1], [value2], ...)

    Thanks to CzarJunkie

    Detector (18th April 2014)  


  3. #3
    DF VIP Member Undertaker's Avatar
    Join Date
    Nov 2000
    Location
    Earth
    Posts
    2,533
    Thanks
    39
    Thanked:        189
    Karma Level
    477

    Default Re: need help with some code for visual basic - asap if you can lads ------

    alternatively call a stored procedure and pass the variables
    plus the added benefit that if you want to make any changes you can do it at db level rather than releasing a new app

    ps: you storing password in plain text? might want to look at hashing
    Last edited by Undertaker; 18th April 2014 at 11:38 PM.

    Thanks to Undertaker

    Detector (18th April 2014)  


  4. #4
    Inactive
    Detector's Avatar
    Join Date
    Jun 2001
    Location
    Grim North
    Posts
    7,483
    Thanks
    2,587
    Thanked:        2,712
    Karma Level
    1040

    Default Re: need help with some code for visual basic - asap if you can lads ------

    @undertaker, just changing it to 4.1 new hashing m8, wanted to get it working using ,4.1 first to test fully

    still not working
    A wise man once said " "

  5. #5
    DF VIP Member Undertaker's Avatar
    Join Date
    Nov 2000
    Location
    Earth
    Posts
    2,533
    Thanks
    39
    Thanked:        189
    Karma Level
    477

    Default Re: need help with some code for visual basic - asap if you can lads ------

    ever thought of moving to c# instead of vb?

    i've recently gotten into programming, namely bespoke web applications for the NHS. Never knew it could be so much fun!!!

  6. #6
    Inactive
    Detector's Avatar
    Join Date
    Jun 2001
    Location
    Grim North
    Posts
    7,483
    Thanks
    2,587
    Thanked:        2,712
    Karma Level
    1040

    Default Re: need help with some code for visual basic - asap if you can lads ------

    ive not bothered with c yet m8, im love the simplicity and freedom of visual basic and have done around 65 full apps so far and loving every minute of it.

    this is doing my heed in though
    A wise man once said " "

  7. #7
    Inactive
    Detector's Avatar
    Join Date
    Jun 2001
    Location
    Grim North
    Posts
    7,483
    Thanks
    2,587
    Thanked:        2,712
    Karma Level
    1040

    Default Re: need help with some code for visual basic - asap if you can lads ------

    Quote Originally Posted by CzarJunkie View Post
    INSERT INTO [tablename] ( [column1], [column2], ... ) VALUES ( [value1], [value2], ...)
    sql syntax error m8 somewhere
    A wise man once said " "

  8. #8
    DF VIP Member Undertaker's Avatar
    Join Date
    Nov 2000
    Location
    Earth
    Posts
    2,533
    Thanks
    39
    Thanked:        189
    Karma Level
    477

    Default Re: need help with some code for visual basic - asap if you can lads ------

    its the commas' you don't need one after the last column name and last value

  9. #9
    Inactive
    Detector's Avatar
    Join Date
    Jun 2001
    Location
    Grim North
    Posts
    7,483
    Thanks
    2,587
    Thanked:        2,712
    Karma Level
    1040

    Default Re: need help with some code for visual basic - asap if you can lads ------

    still not working.
    A wise man once said " "

  10. #10
    Inactive
    Detector's Avatar
    Join Date
    Jun 2001
    Location
    Grim North
    Posts
    7,483
    Thanks
    2,587
    Thanked:        2,712
    Karma Level
    1040

    Default Re: need help with some code for visual basic - asap if you can lads ------

    right what about this, its only saving the first savenames(SQLStatement#) though. if I select 2 it will save the password and not username, if I put the savenames(SQLStatement) first it will save the username and not password. it also throws up an error afterwards
    Dim
    SQLStatement AsString = "Insert INTO user(username) VALUES ('" & txtName.Text & "')"


    Dim SQLStatement2 AsString = "Insert INTO user(pwr) VALUES ('" & txtPassword.Text & "')"

    savenames(SQLStatement2)

    savenames(SQLStatement)
    A wise man once said " "

  11. #11
    DF VIP Member Undertaker's Avatar
    Join Date
    Nov 2000
    Location
    Earth
    Posts
    2,533
    Thanks
    39
    Thanked:        189
    Karma Level
    477

    Default Re: need help with some code for visual basic - asap if you can lads ------

    what is the error you getting on the combined sql statement?

  12. #12
    DF VIP Member blacksheep's Avatar
    Join Date
    Jun 2006
    Location
    Manchester
    Posts
    3,877
    Thanks
    87
    Thanked:        265
    Karma Level
    545

    Default Re: need help with some code for visual basic - asap if you can lads ------

    Ruby on Rails - point it at the db and it will auto generate pages to edit each table.

  13. #13
    DF VIP Member akimba's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    2,846
    Thanks
    1,034
    Thanked:        783
    Karma Level
    368

    Default Re: need help with some code for visual basic - asap if you can lads ------

    Whats the savenames sub I think might be an issue in that rather than these strings

    Also I am guessing this is due to posting but should be "As String" with a space not "AsString" etc

Similar Threads

  1. Code for Blaupunkt Car 300 Radio?
    By fais in forum Radio Decoding
    Replies: 8
    Last Post: 30th March 2004, 03:38 PM
  2. visual basic 6 enterprise
    By spade2001 in forum Programming
    Replies: 21
    Last Post: 14th September 2002, 10:51 AM
  3. Visual basic Any one!
    By magic1 in forum The Dog and Duck
    Replies: 2
    Last Post: 8th September 2002, 02:05 PM
  4. sony z5:security code
    By Danger Mouse in forum Unlocking Questions & Solutions
    Replies: 1
    Last Post: 6th September 2002, 05:41 PM
  5. Eurotunnel cheap fare or discount code - priviledge member?
    By shedsounds in forum Cheapskates Corner
    Replies: 2
    Last Post: 5th September 2002, 10:21 AM

Social Networking 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
  •