|
-
Nov 18th, 2010, 01:58 PM
#1
Thread Starter
Addicted Member
Decreasing a field
hi all am using vs2010
here is my connection string
Code:
Dim MySQLConnection As MySqlConnection
MySqlConnection = New MySqlConnection
MySQLConnection.ConnectionString = "server=db4free.net;Port=3306; User ID=seifhatem; password=11; database=huaweiunlocking"
MySqlConnection.Open()
Dim MyAdapter As New MySqlDataAdapter
Dim SqlQuary = "SELECT * From Users WHERE Username='" & usernametextbox.Text & "' AND password = '" & passwordtextbox.Text & "';"
Dim Command As New MySqlCommand
Command.Connection = MySqlConnection
Command.CommandText = SqlQuary
MyAdapter.SelectCommand = Command
Dim Mydata As MySqlDataReader
Mydata = Command.ExecuteReader
If Mydata.HasRows = 0 Then
MsgBox("Error During Login:Please Enter Valid Data")
Else
End If
I want a command that decreases the field called Credits in the database and i will write between else and end if
like if the user clicks the button it connects and decrease 1 credit thx in advance
-
Nov 18th, 2010, 04:30 PM
#2
Re: Decreasing a field
What is the structure of the table?
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
Nov 18th, 2010, 05:35 PM
#3
Thread Starter
Addicted Member
Re: Decreasing a field
ID,Username,Password and Credit(which i want yo decrease it)
Thx in asvance
-
Nov 18th, 2010, 06:11 PM
#4
Lively Member
Re: Decreasing a field
What is the datatype of credit? So you're wanting to do an update statement to decrease by 1 every record returned by SqlQuary? Am I understanding your need correctly?
-
Nov 18th, 2010, 06:33 PM
#5
Thread Starter
Addicted Member
Re: Decreasing a field
Yes u'r right and the type is varchar
-
Nov 18th, 2010, 06:45 PM
#6
Lively Member
Re: Decreasing a field
is there a reason you're not using an integer datatype? it just holds numeric data, correct?
-
Nov 18th, 2010, 08:12 PM
#7
Re: Decreasing a field
So you need to use an update query to decrease by one and as gtrahern suggested you may be better of using some numeric type.
So what is the problem you have?
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Nov 19th, 2010, 02:42 AM
#8
Thread Starter
Addicted Member
Re: Decreasing a field
Ok and after changing it to integer
How can i edit it using vb.net
-
Nov 19th, 2010, 09:08 AM
#9
Re: Decreasing a field
 Originally Posted by salmawy
Ok and after changing it to integer
How can i edit it using vb.net
Fetch the value to a variable.
Update the value of the variable by subtracting 1 from it.
Update the table with the value of the variable.
Do you want the code for this?
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
Nov 19th, 2010, 09:58 AM
#10
Thread Starter
Addicted Member
Re: Decreasing a field
What is thecode to do these things
-
Nov 19th, 2010, 09:59 AM
#11
Thread Starter
Addicted Member
Re: Decreasing a field
Because this is my first time to work with sql
-
Nov 19th, 2010, 10:05 AM
#12
Re: Decreasing a field
 Originally Posted by salmawy
What is thecode to do these things
Running an update statement is the easiest way to do it.
UPDATE USERS SET CREDIT = CREDIT -1 WHERE USERNAME = 'USER'
You'll need to replace some of the values in the sql statement. To figure out how to execute this statement, look up the tutorials on this forum.
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
Nov 19th, 2010, 10:09 AM
#13
Thread Starter
Addicted Member
Re: Decreasing a field
Do i need to excute it using
Sql qyary
-
Nov 19th, 2010, 10:10 AM
#14
Re: Decreasing a field
 Originally Posted by salmawy
Do i need to excute it using
Sql qyary
To execute this SQL Query, you'll need a connection string, a command object and a parameter object.
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
Nov 19th, 2010, 10:12 AM
#15
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
Nov 19th, 2010, 10:14 AM
#16
Thread Starter
Addicted Member
Re: Decreasing a field
I am usingmysql connecter/net 6.0.7 as refrence and the connection string is in post 1 i did the connection
-
Nov 19th, 2010, 06:54 PM
#17
Re: Decreasing a field
I don't think there are many differences.
Just use a mysql tutorial.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
Tags for this Thread
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
|