help this n00b

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
 
K

Ken Tucker [MVP]

Hi,

Why dont you create a new connection and command variable instead of
using the old ones after you check to see you can update the other database.
Please post the exact error message.

Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top