473,479 Members | 2,060 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Increase value by 1. How to do this?

Hello,

I have a database table with 2 fields: [id] and [value];

I need to create a function which increases by 1 the number in [value]
field for a certain id.

In this moment I have the following:

Private Sub Vote()

' Set Connection
Dim connectionString As String = AppSettings("connectionString")
Dim dbConnection As IDbConnection =
NewOleDbConnection(connectionString)

' Set Query and Command
Dim queryString As String = "SELECT [t_query].* FROM [t_query] WHERE
([t_query].[id] = @id)"
Dim dbCommand As IDbCommand = New OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

' Add Parameter
dbCommand.Parameters.Add(New OleDbParameter("@id", id))

' Update value ???
dbConnection.Open()
Try
?????
Finally
dbConnection.Close()
End Try

End Sub

I need to know how to increase the [value] number by 1.

Thanks,
Miguel

Nov 19 '05 #1
3 2359
Whats this got to do with ASP.NET?

To do this in code just execute a scalar and type to the appropriate numeric
type then add one and send an update back to the database. Although you
could just as easily do this in SQL.

Richard

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:uf**************@tk2msftngp13.phx.gbl...
Hello,

I have a database table with 2 fields: [id] and [value];

I need to create a function which increases by 1 the number in [value]
field for a certain id.

In this moment I have the following:

Private Sub Vote()

' Set Connection
Dim connectionString As String = AppSettings("connectionString")
Dim dbConnection As IDbConnection =
NewOleDbConnection(connectionString)

' Set Query and Command
Dim queryString As String = "SELECT [t_query].* FROM [t_query] WHERE
([t_query].[id] = @id)"
Dim dbCommand As IDbCommand = New OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

' Add Parameter
dbCommand.Parameters.Add(New OleDbParameter("@id", id))

' Update value ???
dbConnection.Open()
Try
?????
Finally
dbConnection.Close()
End Try

End Sub

I need to know how to increase the [value] number by 1.

Thanks,
Miguel

Nov 19 '05 #2
Hi,

I don't know if I am getting it.
My first idea was to load the record [value] field using a datareader
and place it in a variable. Then I increase the variable's value by 1
and finally I update my record.

Well, this is an idea. But is this the best way?

When you say to use SQL you say a procedure? I am using Access?

Thanks,
Miguel

"Richard Myers" <no**@ofurbusiness.com> wrote in message
news:no**@ofurbusiness.com:
Whats this got to do with ASP.NET?

To do this in code just execute a scalar and type to the appropriate numeric
type then add one and send an update back to the database. Although you
could just as easily do this in SQL.

Richard

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:uf**************@tk2msftngp13.phx.gbl...
Hello,

I have a database table with 2 fields: [id] and [value];

I need to create a function which increases by 1 the number in [value]
field for a certain id.

In this moment I have the following:

Private Sub Vote()

' Set Connection
Dim connectionString As String = AppSettings("connectionString")
Dim dbConnection As IDbConnection =
NewOleDbConnection(connectionString)

' Set Query and Command
Dim queryString As String = "SELECT [t_query].* FROM [t_query] WHERE
([t_query].[id] = @id)"
Dim dbCommand As IDbCommand = New OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

' Add Parameter
dbCommand.Parameters.Add(New OleDbParameter("@id", id))

' Update value ???
dbConnection.Open()
Try
?????
Finally
dbConnection.Close()
End Try

End Sub

I need to know how to increase the [value] number by 1.

Thanks,
Miguel


Nov 19 '05 #3
Yep its quite simple.

UPDATE MyTable SET MyTable.MyCol = (MyTable.MyCol+1) WHERE
(((MyTable.MyOtherCol)=5));

Obviously you can drop/enhance the criteria as required.

Richard
"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:eO**************@TK2MSFTNGP14.phx.gbl...
Hi,

I don't know if I am getting it.
My first idea was to load the record [value] field using a datareader
and place it in a variable. Then I increase the variable's value by 1
and finally I update my record.

Well, this is an idea. But is this the best way?

When you say to use SQL you say a procedure? I am using Access?

Thanks,
Miguel

"Richard Myers" <no**@ofurbusiness.com> wrote in message
news:no**@ofurbusiness.com:
Whats this got to do with ASP.NET?

To do this in code just execute a scalar and type to the appropriate numeric type then add one and send an update back to the database. Although you
could just as easily do this in SQL.

Richard

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:uf**************@tk2msftngp13.phx.gbl...
Hello,

I have a database table with 2 fields: [id] and [value];

I need to create a function which increases by 1 the number in [value]
field for a certain id.

In this moment I have the following:

Private Sub Vote()

' Set Connection
Dim connectionString As String = AppSettings("connectionString")
Dim dbConnection As IDbConnection =
NewOleDbConnection(connectionString)

' Set Query and Command
Dim queryString As String = "SELECT [t_query].* FROM [t_query] WHERE
([t_query].[id] = @id)"
Dim dbCommand As IDbCommand = New OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

' Add Parameter
dbCommand.Parameters.Add(New OleDbParameter("@id", id))

' Update value ???
dbConnection.Open()
Try
?????
Finally
dbConnection.Close()
End Try

End Sub

I need to know how to increase the [value] number by 1.

Thanks,
Miguel

Nov 19 '05 #4

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

Similar topics

2
2138
by: Miguel Dias Moura | last post by:
Hello, I have a dataset (users) on an ASP.NET/VB page (detail.aspx). A record on this dataset (users) has 3 fields: "id", "username", "visits". The page detail.aspx is called with a...
3
3568
by: Edwin New | last post by:
I need to increase the number of connections to PostgreSQL 7.2.1. I have tried changing the value of max_connections in Postgresql.conf. It was commented out (as are all other entries except...
2
3825
by: msnews.microsoft.com | last post by:
Hi all I am working on an application for a touch screen terminal. I have placed a datagrid on the form and the user will select a row on the datagrid. I have increased the font size on the...
5
19283
by: ipy2006 | last post by:
Hi All: In the table XYZ.ORD_DTL the column PDT_DESC is CHAR(35). I want to increase it to CHAR(100). However, I am getting the following error. Please help! db2 =alter table XYZ.ORD_DTL alter...
4
58427
by: =?Utf-8?B?c2FtZWVy?= | last post by:
environment : .net framework 1.1, ado.net, visual studio 2003, vb, sqlsever 2000, winforms, webforms I want to increase the timout of the webservice in the application which is being used in a...
0
1581
by: herre | last post by:
I wonder if there is a sql command or another way to increase sequence value more than one without modify de increment value of the sequence. I have to do that because in some problems i need to...
3
2922
by: nineoo | last post by:
To all, Ok , now this may sound a little crazy, but does any one know if there is a way to increase the maximum value of a unsigned long int? I'm aware of the the max value of an...
1
2799
by: Victor Hadianto | last post by:
Hi, I have a WPF ScrollBar that had a rather large maximum value. Now the problem is that everytime I click the RepeatButton (the buttons on both side of the Thumb button) it only increases the...
4
4829
by: zoeb | last post by:
Hi. I have a form which the user enters 2 years worth of data into (one record per year). The aim, is to populate the table this form is based on with 3 more years worth of data (i.e. creating 3...
0
7033
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7027
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7071
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
6861
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...
0
4468
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2987
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...
0
2974
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1291
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 ...
1
557
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.