473,382 Members | 1,225 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,382 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 1246
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.