-3

I have a database table with three columns: User, Pass, Money. I also have a vb form with a button and a TextBox named Money. What's the query code for updating the Money in the database, so it would be the same as the TextBox in the form?

ɐsɹǝʌ ǝɔıʌ
  • 4,440
  • 3
  • 35
  • 56
Jace K
  • 11
  • 2

3 Answers3

1

Check Link , You are probably looking for it .

an update query can be

UPDATE Categories 
SET Money = @MoneyTextBox WHERE (user =   @currentUser)
Zee
  • 381
  • 2
  • 11
1

With this piece of code you should be able to connect and update an Access database

Dim Connection As New OledbConnection("Provider=microsoft.Jet.oledb.4.0;DataSource=YourDatabase.mdb;") 

        Try               
            Connection.Open()

            Dim Query = "UPDATE TableName SET Money = ? WHERE User = ?"
            Dim command As New OleDbCommand
            With command
                .CommandText = Query
                .Connection = Connection
                .Parameters.AddWithValue("@p1", MoneyTextBox.Text)
                .Parameters.AddWithValue("@p2", UserTextBox.Text)
            End With

            command.ExecuteNonQuery()

        Catch exception As Exception
            MessageBox.Show(exception.Message)
        Finally
            Connection.Close()
        End Try
ɐsɹǝʌ ǝɔıʌ
  • 4,440
  • 3
  • 35
  • 56
0

use Update Query

"update Databasename set Money='"& MoneyTextBox.Text &"' where user='" & UserTextBox.Text &"' and Pass='"PassTextBox.Text"' "
  • Also that's not the best way to update a database. Using parameterized query you'll avoid SQL Injection attacks. Take a look: http://stackoverflow.com/questions/332365/how-does-the-sql-injection-from-the-bobby-tables-xkcd-comic-work – ɐsɹǝʌ ǝɔıʌ Feb 25 '14 at 10:50