|
-
Aug 6th, 2003, 12:12 PM
#1
Thread Starter
Member
Update statement not working?
I'm stuck with my update statement for a access2000 file.
I have a table called email with 2 fields. (name and email)
I can Add to it just fine, but I can't update.
This is what I have
in my access table I have
Name Email
perry [email protected]
peter [email protected]
value1 = "newname"
Dim mycn As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "C:/donation.mdb")
Dim mycmd As OleDbCommand = New OleDbCommand
mycmd.Connection = mycn
mycmd.CommandText = "UPDATE email SET name=value1 WHERE name='perry' AND email='[email protected]')"
mycn.Open()
mycmd.ExecuteNonQuery()
mycn.Close()
it will fail on mycmd.ExecuteNonQuery()
What am I doing wrong?
-
Aug 6th, 2003, 12:19 PM
#2
Basic string concantenation
VB Code:
mycmd.CommandText = "UPDATE email SET name='" & value1 & "' WHERE name='perry' AND email=' [email protected]')"
-
Aug 6th, 2003, 01:27 PM
#3
Thread Starter
Member
changed it to
mycmd.CommandText = "UPDATE email SET name='hello' WHERE name='perry' AND email='[email protected]'"
and still not working.
-
Aug 6th, 2003, 01:47 PM
#4
-
Aug 6th, 2003, 02:29 PM
#5
Thread Starter
Member
Object reference not set to an instance of an object
in this line
mycon.UpdateCommand.CommandText = "UPDATE email SET name='hello' WHERE name='perry' AND email='[email protected]'"
-
Aug 6th, 2003, 02:39 PM
#6
Thread Starter
Member
please forget my last comment.
It's working now...
forgot that "[email protected]" was not in the database. duh....
Thanks so much for helping me out.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|