473,325 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

help this n00b

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.CloseConnecti on)
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

Nov 20 '05 #1
1 1244
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
-------------------------
"CosmicLogick" <lo****@ananzi.co-dot-za.no-spam.invalid> wrote in message
news:40**********@127.0.0.1...
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.CloseConnecti on)
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

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Matt | last post by:
I'd like to overwrite just one line of a binary file, based on a position set by seek(). Is there no way to do this? As far as I can tell I need to read the whole file, change the line, and write...
12
by: Christo | last post by:
borland c++ 5.01 character constant must be one or two characters long get this when compiling my first c++ program can anyone out there help? it is highlighting this line as the problem ...
3
by: Anupam Kapoor | last post by:
hi all, a python n00b, so please bear with me. i have a simple question: i generally name python sources as a-simple-python-example.py. when i try to import a module named as above, i...
1
by: newgenre | last post by:
I am using a pre-built package of code for my site, which is called EasyDisc. All it does is it creates an interactive forum on your site, like any forum you see anywhere. I am having a problem...
2
by: ducky | last post by:
Hi all, The only programming experience i have under my belt so far is VB. I'm just starting out on C++ and wonder if anybody suggests and good (free) starting points for me to get going. I'm...
8
by: HardHackz | last post by:
Hey, I'm trying to learn C++, the problem is, when I do cout << "Hello World!"; it always opens dos and closes it to quickly to see...i know im a total n00b, but any help?
0
by: hockeyjk | last post by:
All, I'm writing a program that creates a histogram of data. IDLE is freezing up after the window opens (doesn't prompt user or graph anything). The window that opens is named "tk" rather than...
2
by: benwah1983 | last post by:
Greetings, Here is my problem: The following code shows a div with two small nested divs (images with a title), then the div is closed. Another one opens and a "random text" is displayed. <div...
4
by: ig | last post by:
First off, I'm a python n00b, so feel free to comment on anything if I'm doing it "the wrong way." I'm building a discrete event simulation tool. I wanted to use coroutines. However, I want to know...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.