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

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

  1. Detector's Avatar

    Detector said:

    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. CzarJunkie's Avatar

    CzarJunkie said:

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

    INSERT INTO [tablename] ( [column1], [column2], ... ) VALUES ( [value1], [value2], ...)
     
  3. Undertaker's Avatar

    Undertaker said:

    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.
     
  4. Detector's Avatar

    Detector said:

    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. Undertaker's Avatar

    Undertaker said:

    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. Detector's Avatar

    Detector said:

    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. Detector's Avatar

    Detector said:

    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. Undertaker's Avatar

    Undertaker said:

    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. Detector's Avatar

    Detector said:

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

    still not working.
    A wise man once said " "
     
  10. Detector's Avatar

    Detector said:

    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. Undertaker's Avatar

    Undertaker said:

    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. blacksheep's Avatar

    blacksheep said:

    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. akimba's Avatar

    akimba said:

    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