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
Re: need help with some code for visual basic - asap if you can lads ------
INSERT INTO [tablename] ( [column1], [column2], ... ) VALUES ( [value1], [value2], ...)
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
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
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!!!
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
Re: need help with some code for visual basic - asap if you can lads ------
Quote:
Originally Posted by
CzarJunkie
INSERT INTO [tablename] ( [column1], [column2], ... ) VALUES ( [value1], [value2], ...)
sql syntax error m8 somewhere
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
Re: need help with some code for visual basic - asap if you can lads ------
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)
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?
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.
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