473,779 Members | 2,072 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_CustomerUpd ate()
Dim MyConString As String = ("DRIVER={My SQL ODBC 3.51
Driver};SERVER= 192.168.0.15;DA TABASE=store;UI D=hal
lo;PASSWORD=zom gnone;OPTION=3; ")
Dim MyConnection As New
OdbcConnection( MyConString)
MyConnection.Op en()
Dim MyCommand As New OdbcCommand
MyCommand.Conne ction = MyConnection
MyCommand.Comma ndText = "UPDATE customer SET
First_Name='ZOM G666777' WHERE id=2"
MyCommand.Execu teNonQuery()
MyConnection.Cl ose()
'MyConnection.D ispose()
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 4174
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_CustomerUpd ate()
Dim MyConString As String = ("DRIVER={My SQL ODBC 3.51
Driver};SERVER= 192.168.0.15;DA TABASE=store;UI D=hal
lo;PASSWORD=zom gnone;OPTION=3; ")
Dim MyConnection As New
OdbcConnection( MyConString)
MyConnection.Op en()
Dim MyCommand As New OdbcCommand
MyCommand.Conne ction = MyConnection
MyCommand.Comma ndText = "UPDATE customer SET
First_Name='ZOM G666777' WHERE id=2"
MyCommand.Execu teNonQuery()
MyConnection.Cl ose()
'MyConnection.D ispose()
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_CustomerUpd ate()
Dim MyConString As String = ("DRIVER={My SQL ODBC 3.51
Driver};SERVER= 192.168.0.15;DA TABASE=store;UI D=hal
lo;PASSWORD=zom gnone;OPTION=3; ")
Dim MyConnection As New OdbcConnection( MyConString)
Try
MyConnection.Op en()
Dim MyCommand As New OdbcCommand
MyCommand.Conne ction = MyConnection
MyCommand.Comma ndText = "UPDATE customer SET
First_Name='ZOM G666777' WHERE id=2"
MyCommand.Execu teNonQuery()
Catch ex As Exception
Trace.Warn(ex.T oString())
Finally
MyConnection.Cl ose()
'MyConnection.D ispose()
End Function

--

Jos
Nov 21 '05 #2
Jos
Jos wrote:

Sorry, forgot the END TRY:

Private Function SQL_CustomerUpd ate()
Dim MyConString As String = ("DRIVER={My SQL ODBC 3.51
Driver};SERVER= 192.168.0.15;DA TABASE=store;UI D=hal
lo;PASSWORD=zom gnone;OPTION=3; ")
Dim MyConnection As New OdbcConnection( MyConString)
Try
MyConnection.Op en()
Dim MyCommand As New OdbcCommand
MyCommand.Conne ction = MyConnection
MyCommand.Comma ndText = "UPDATE customer SET
First_Name='ZOM G666777' WHERE id=2"
MyCommand.Execu teNonQuery()
Catch ex As Exception
Trace.Warn(ex.T oString())
Finally
MyConnection.Cl ose()
'MyConnection.D ispose()
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_CustomerUpd ate()
Dim MyConString As String = ("DRIVER={My SQL ODBC 3.51
Driver};SERVER= 192.168.0.15;DA TABASE=store;UI D=hal
lo;PASSWORD=zom gnone;OPTION=3; ")
Dim MyConnection As New OdbcConnection( MyConString)
Try
MyConnection.Op en()
Dim MyCommand As New OdbcCommand
MyCommand.Conne ction = MyConnection
MyCommand.Comma ndText = "UPDATE customer SET
First_Name='ZOM G666777' WHERE id=2"
MyCommand.Execu teNonQuery()
Catch ex As Exception
Trace.Warn(ex.T oString())
Finally
MyConnection.Cl ose()
'MyConnection.D ispose()
End Try
End Function

--

Jos Branders

Nov 21 '05 #4
Do you get an error? If so, what is it?
"HydroSan" <hy***@sankyu u-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_CustomerUpd ate()
Dim MyConString As String = ("DRIVER={My SQL ODBC 3.51
Driver};SERVER= 192.168.0.15;DA TABASE=store;UI D=hal
lo;PASSWORD=zom gnone;OPTION=3; ")
Dim MyConnection As New
OdbcConnection( MyConString)
MyConnection.Op en()
Dim MyCommand As New OdbcCommand
MyCommand.Conne ction = MyConnection
MyCommand.Comma ndText = "UPDATE customer SET
First_Name='ZOM G666777' WHERE id=2"
MyCommand.Execu teNonQuery()
MyConnection.Cl ose()
'MyConnection.D ispose()
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
3948
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 version of this document can be found at: http://prdownloads.sourceforge.net/souptonuts/README_mysql.txt?download
15
4644
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 communicate with a MySQL database table on a web server, from inside of my company's Access-VBA application. I know VBA pretty well but have never before needed to do this HTTP/XML/MySQL type functions.
4
3701
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 that starting on 4/25/2006 the dump files are empty and only shows a few lines of comments or something instead of creating a normal dump as it had been doing just fine for the last few weeks. Quote:
1
2040
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 =& DB::connect('mysql://user:password@localhost/dbname'); if (PEAR::isError($db)) { die($db->getMessage());
4
3002
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 with data from the database, allow the user to update it, and then display the form again with POST data. I can get the data out of the database and get the user updates back into the database, but how do I get the filled-out form back to the user...
6
38520
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 through this without much trouble. Programming knowledge is not required. Index What is SQL? Why MySQL? Installing MySQL. Using the MySQL command line interface
1
3765
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 file, but many are able to read the files (or tables entities). I am not sure if I need to lock the tables in my Java code or do I lock the tables within the MySQL syntax. I'm just a little confused on the matter. This java code is a working...
1
4610
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 Database but I'm stuck in the EDIT. I'm getting 2 problems over here. Below is the description: 1)The FIRST page will list all the records from the table which Admin can EDIT with CHECKBOX for each record to select. He can select one or more than one...
1
9586
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 things (stored procedures, functions).. we have to manually edit. That time, we face some interesting challenges.. I failed to document all of them, but whatever I can share with u.. I will try.. :) ...
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10075
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9931
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8961
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5504
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.