Close

Results 1 to 13 of 13
  1. #1
    Inactive
    Detector's Avatar
    Join Date
    Jun 2001
    Location
    Grim North
    Posts
    7,458
    Thanks
    2,574
    Thanked:        2,697
    Karma Level
    1110

    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,756
    Thanks
    832
    Thanked:        3,222
    Karma Level
    2170

    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,527
    Thanks
    39
    Thanked:        184
    Karma Level
    422

    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,458
    Thanks
    2,574
    Thanked:        2,697
    Karma Level
    1110

    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,527
    Thanks
    39
    Thanked:        184
    Karma Level
    422

    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,458
    Thanks
    2,574
    Thanked:        2,697
    Karma Level
    1110

    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,458
    Thanks
    2,574
    Thanked:        2,697
    Karma Level
    1110

    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,527
    Thanks
    39
    Thanked:        184
    Karma Level
    422

    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,458
    Thanks
    2,574
    Thanked:        2,697
    Karma Level
    1110

    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,458
    Thanks
    2,574
    Thanked:        2,697
    Karma Level
    1110

    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,527
    Thanks
    39
    Thanked:        184
    Karma Level
    422

    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 Jedi blacksheep's Avatar
    Join Date
    Jun 2006
    Location
    Manchester
    Posts
    3,877
    Thanks
    87
    Thanked:        265
    Karma Level
    487

    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 Jedi akimba's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    2,830
    Thanks
    1,023
    Thanked:        779
    Karma Level
    299

    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. [REQUEST] advice or help with a visual basic program/code
    By Detector in forum Programming
    Replies: 31
    Last Post: 20th September 2012, 05:11 PM
  2. Visual Basic + MSN
    By Spennyboy in forum The Dog and Duck
    Replies: 7
    Last Post: 9th August 2004, 11:33 PM
  3. Visual basic
    By hitmandk1985 in forum Website Coding & Graphics
    Replies: 4
    Last Post: 11th June 2003, 12:19 PM
  4. Visual Basic 6
    By Digi Program in forum Website Coding & Graphics
    Replies: 2
    Last Post: 15th October 2002, 08:11 PM
  5. Visual basic Any one!
    By magic1 in forum The Dog and Duck
    Replies: 2
    Last Post: 8th September 2002, 02:05 PM

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
  •