C
CosmicLogick
This following piece of code wont work, i have no idea what i did
wrong.
Data.mdb is the database file
Admin is the table
username and password are fields
oldpasstxt.Text and newpasstxt.Text are from input boxes.
The error vs.net gives me is
olecmd.ExecuteNonQuery()
on the 3rd last line of what i pasted.
any help would be deeply appreciated :{
code:
Private Sub okchange_btn_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles okchange_btn.Click
Dim conn As OleDbConnection
Dim query As String
Dim adapter As OleDbDataAdapter
Dim ds As DataSet
Dim connstring As String
Dim olecmd As OleDbCommand
Dim ole As String
connstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Data.mdb;
Jet OLEDB:database password=password"
conn = New OleDbConnection(connstring)
query = "select * from Admin where username = 'admin' and Password =
'" & oldpasstxt.Text & "'"
olecmd = New OleDbCommand(query, conn)
conn.Open()
Dim dr = olecmd.ExecuteReader(CommandBehavior.CloseConnection)
If dr.Read = True Then
connstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Logick.cos;
Jet OLEDB:database password=cosmiclogick"
conn = New OleDbConnection(connstring)
query = "UPDATE Admin SET password = ('" & newpasstxt.Text &
"') where username = 'admin'"
olecmd = New OleDbCommand(query, conn)
conn.Open()
olecmd = New OleDbCommand(query, conn)
olecmd.ExecuteNonQuery()
conn.Close()
End Sub
wrong.
Data.mdb is the database file
Admin is the table
username and password are fields
oldpasstxt.Text and newpasstxt.Text are from input boxes.
The error vs.net gives me is
olecmd.ExecuteNonQuery()
on the 3rd last line of what i pasted.
any help would be deeply appreciated :{
code:
Private Sub okchange_btn_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles okchange_btn.Click
Dim conn As OleDbConnection
Dim query As String
Dim adapter As OleDbDataAdapter
Dim ds As DataSet
Dim connstring As String
Dim olecmd As OleDbCommand
Dim ole As String
connstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Data.mdb;
Jet OLEDB:database password=password"
conn = New OleDbConnection(connstring)
query = "select * from Admin where username = 'admin' and Password =
'" & oldpasstxt.Text & "'"
olecmd = New OleDbCommand(query, conn)
conn.Open()
Dim dr = olecmd.ExecuteReader(CommandBehavior.CloseConnection)
If dr.Read = True Then
connstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Logick.cos;
Jet OLEDB:database password=cosmiclogick"
conn = New OleDbConnection(connstring)
query = "UPDATE Admin SET password = ('" & newpasstxt.Text &
"') where username = 'admin'"
olecmd = New OleDbCommand(query, conn)
conn.Open()
olecmd = New OleDbCommand(query, conn)
olecmd.ExecuteNonQuery()
conn.Close()
End Sub