473,386 Members | 1,647 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,386 software developers and data experts.

MySQL: UPDATE not working

Having a bit of a problem getting UPDATE working. The project in
question is a simple MySQL VB.NET frontend, allowing Insertion,
Selection, and others.

Well, I've gotten Drop and Insert working, but to edit a table row,
I'd like to use Update.

I have the following code in a class:

Private Function SQL_CustomerUpdate()
Dim MyConString As String = ("DRIVER={MySQL ODBC 3.51
Driver};SERVER=192.168.0.15;DATABASE=store;UID=hal
lo;PASSWORD=zomgnone;OPTION=3;")
Dim MyConnection As New
OdbcConnection(MyConString)
MyConnection.Open()
Dim MyCommand As New OdbcCommand
MyCommand.Connection = MyConnection
MyCommand.CommandText = "UPDATE customer SET
First_Name='ZOMG666777' WHERE id=2"
MyCommand.ExecuteNonQuery()
MyConnection.Close()
'MyConnection.Dispose()
End Function

Keep in mind that the UPDATE syntax was much more complex, but I'm
trying to get it working at a very simple level so I can see if it
actually works or not.

It doesn't. :(

Can anyone help?

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
Nov 21 '05 #1
5 4153
Jos
HydroSan wrote:
Having a bit of a problem getting UPDATE working. The project in
question is a simple MySQL VB.NET frontend, allowing Insertion,
Selection, and others.

Well, I've gotten Drop and Insert working, but to edit a table row,
I'd like to use Update.

I have the following code in a class:

Private Function SQL_CustomerUpdate()
Dim MyConString As String = ("DRIVER={MySQL ODBC 3.51
Driver};SERVER=192.168.0.15;DATABASE=store;UID=hal
lo;PASSWORD=zomgnone;OPTION=3;")
Dim MyConnection As New
OdbcConnection(MyConString)
MyConnection.Open()
Dim MyCommand As New OdbcCommand
MyCommand.Connection = MyConnection
MyCommand.CommandText = "UPDATE customer SET
First_Name='ZOMG666777' WHERE id=2"
MyCommand.ExecuteNonQuery()
MyConnection.Close()
'MyConnection.Dispose()
End Function

Keep in mind that the UPDATE syntax was much more complex, but I'm
trying to get it working at a very simple level so I can see if it
actually works or not.

It doesn't. :(


You didn't tell us what happens. Do you get an error message or not?

If there's no error message, check if there really is a record with ID=2.

It also helps if you wrap your code in a Try Catch exception block, like
this:

Private Function SQL_CustomerUpdate()
Dim MyConString As String = ("DRIVER={MySQL ODBC 3.51
Driver};SERVER=192.168.0.15;DATABASE=store;UID=hal
lo;PASSWORD=zomgnone;OPTION=3;")
Dim MyConnection As New OdbcConnection(MyConString)
Try
MyConnection.Open()
Dim MyCommand As New OdbcCommand
MyCommand.Connection = MyConnection
MyCommand.CommandText = "UPDATE customer SET
First_Name='ZOMG666777' WHERE id=2"
MyCommand.ExecuteNonQuery()
Catch ex As Exception
Trace.Warn(ex.ToString())
Finally
MyConnection.Close()
'MyConnection.Dispose()
End Function

--

Jos
Nov 21 '05 #2
Jos
Jos wrote:

Sorry, forgot the END TRY:

Private Function SQL_CustomerUpdate()
Dim MyConString As String = ("DRIVER={MySQL ODBC 3.51
Driver};SERVER=192.168.0.15;DATABASE=store;UID=hal
lo;PASSWORD=zomgnone;OPTION=3;")
Dim MyConnection As New OdbcConnection(MyConString)
Try
MyConnection.Open()
Dim MyCommand As New OdbcCommand
MyCommand.Connection = MyConnection
MyCommand.CommandText = "UPDATE customer SET
First_Name='ZOMG666777' WHERE id=2"
MyCommand.ExecuteNonQuery()
Catch ex As Exception
Trace.Warn(ex.ToString())
Finally
MyConnection.Close()
'MyConnection.Dispose()
End Try
End Function

--

Jos Branders
Nov 21 '05 #3
there s a .NET connector for mysql that doesn t use odbc sources in c#
binary release available too
100% dotnet is better :)
http://dev.mysql.com/downloads/connector/net/1.0.html

"Jos" <jn*************@fastmail.fm> a écrit dans le message de news:
uO**************@TK2MSFTNGP14.phx.gbl...
Jos wrote:

Sorry, forgot the END TRY:

Private Function SQL_CustomerUpdate()
Dim MyConString As String = ("DRIVER={MySQL ODBC 3.51
Driver};SERVER=192.168.0.15;DATABASE=store;UID=hal
lo;PASSWORD=zomgnone;OPTION=3;")
Dim MyConnection As New OdbcConnection(MyConString)
Try
MyConnection.Open()
Dim MyCommand As New OdbcCommand
MyCommand.Connection = MyConnection
MyCommand.CommandText = "UPDATE customer SET
First_Name='ZOMG666777' WHERE id=2"
MyCommand.ExecuteNonQuery()
Catch ex As Exception
Trace.Warn(ex.ToString())
Finally
MyConnection.Close()
'MyConnection.Dispose()
End Try
End Function

--

Jos Branders

Nov 21 '05 #4
Do you get an error? If so, what is it?
"HydroSan" <hy***@sankyuu-dot-com.no-spam.invalid> wrote in message
news:41**********@Usenet.com...
Having a bit of a problem getting UPDATE working. The project in
question is a simple MySQL VB.NET frontend, allowing Insertion,
Selection, and others.

Well, I've gotten Drop and Insert working, but to edit a table row,
I'd like to use Update.

I have the following code in a class:

Private Function SQL_CustomerUpdate()
Dim MyConString As String = ("DRIVER={MySQL ODBC 3.51
Driver};SERVER=192.168.0.15;DATABASE=store;UID=hal
lo;PASSWORD=zomgnone;OPTION=3;")
Dim MyConnection As New
OdbcConnection(MyConString)
MyConnection.Open()
Dim MyCommand As New OdbcCommand
MyCommand.Connection = MyConnection
MyCommand.CommandText = "UPDATE customer SET
First_Name='ZOMG666777' WHERE id=2"
MyCommand.ExecuteNonQuery()
MyConnection.Close()
'MyConnection.Dispose()
End Function

Keep in mind that the UPDATE syntax was much more complex, but I'm
trying to get it working at a very simple level so I can see if it
actually works or not.

It doesn't. :(

Can anyone help?

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*

Nov 21 '05 #5
> Joswrote:
You didn't tell us what happens. Do you get an error message or not?

No error... and it appears that it has magically started working.

I hate when I ask a question then the problem solves itself.

Thanks for all your help. That errortrapping will come in handy one
day.

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
Nov 21 '05 #6

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

Similar topics

0
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
4
by: Robert Blackwell | last post by:
A while ago I had some help from here to make a batch file that would dump my db. Everything was working just fine until 2 days ago and I just found out. I checked my backup folder and found...
1
by: Paul | last post by:
I recently upgraded from MySQL 3.23 to 4.1. Now db is not working properly. I'd very much like your help in solving this issue! Here's the code I used to test it: require_once 'DB.php'; $db...
4
by: dac | last post by:
I am quietly going insane on this project. I've never worked on a project like this one before. All my previous sticky forms were for data entry, not editing. I don't know how to display the form...
6
Atli
by: Atli | last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users. Anyone should be able to get...
1
by: banging | last post by:
Hi there, I have a question regarding locking of tables so that when two or more people try to write or update the mysql tables, it locks up. Basically I only want one person to write to the...
1
by: javediq143 | last post by:
Hi All, This is my first post in this forum. I'm developing a CMS for my latest website. This CMS is also in PhP & MySQL. I'm done with the ADD section where the Admin can INSERT new records in...
1
ssnaik84
by: ssnaik84 | last post by:
Hi Guys, Last year I got a chance to work with R&D team, which was working on DB scripts conversion.. Though there is migration tool available, it converts only tables and constraints.. Rest of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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.