Help me with updating field

seifhatem

New member
Joined
Dec 6, 2010
Messages
1
Programming Experience
Beginner
Hi all
i want to do a program that edits a field by decreasing it by 1
here is what i reached but it doesn't work
Code:
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Dim con As New SqlConnection
Dim cmd As New SqlCommand


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
con.ConnectionString = "Data Source=db4free.net;Initial " Catalog=huaweiunlocking;Persist Security Info=True;User ID=seifhatem;Password=blablabla"
con.Open()
cmd.Connection = con
cmd.CommandText = "UPDATE Users SET Credits = -1"
cmd.ExecuteNonQuery()

Catch ex As Exception
MessageBox.Show("Error while updating record on table..." & ex.Message, "Update Records")
Finally
con.Close()
End Try
End Sub
End Class
Information:
Server:db4free.net
Port:3306
Databasename:huaweiunlocking
table name:users

pls pls pls help me
thx in advance

I am usIng vs2010 and mysql 5.5
 
You're using Sql classes and post in Sql Express forum, but you say you're using MySql database? That is not a match.
 

Latest posts

Back
Top