Dim connectionString As String = ConfigurationManager.ConnectionStrings("SecurityTutorialsConnectionString").ConnectionString
Dim updateSql As String = "UPDATE personnelrequisition SET TotalResume=@TotalResume WHERE PRNo=@PrNo"
Using myConnection As New SqlConnection(connectionString)
myConnection.Open()
Dim myCommand2 As New SqlCommand(updateSql, myConnection)
myCommand2.Parameters.AddWithValue("@PRNo", DropDownList1.SelectedValue())
myCommand2.Parameters.AddWithValue("@TotalResume", +1)
myCommand2.ExecuteNonQuery()
myConnection.Close()
End Using
Please see line myCommand2.Parameters.AddWithValue("@TotalResume", +1), i dont know how to write increment 1, how? anyone can help?
You can just use this bysetting the column increamented by 1, like this below:
Dim connectionString As String = ConfigurationManager.ConnectionStrings("SecurityTutorialsConnectionString").ConnectionString
Dim updateSql As String = "UPDATE personnelrequisition SET TotalResume=TotalResume+1 WHERE
PRNo=@PrNo"
Using myConnection As New SqlConnection(connectionString)
myConnection.Open()
Dim myCommand2 As New SqlCommand(updateSql, myConnection)
Do you mean that you want to know how many records you have in this table? if so storing this value in the database isn't good practice, you can get it simply like this:
munirah-mali...
Member
83 Points
111 Posts
how to add increment '1' in table column-
Oct 21, 2011 06:31 AM|LINK
Hi all, I have one question only regarding how to add '1' in table column. let say i have table like this
+------------------------------------+------------------------------------------------+--------------------------------------+
| PRNo | Job Title + Total Resume |
+------------------------------------+------------------------------------------------+--------------------------------------+
A001 Engineer 0
+------------------------------------+------------------------------------------------+--------------------------------------+
Every time i click save button, how i want to add 1 to totalresume column.
Algorithmn:
1st time click save btton - 0+1 = 1
2nd time click save btton - 1+1 = 2
3rd time click save btton - 2+1 = 3
Total resume column will display 1 for 1st time click save btton and soo on. Any can explain how to do?
reetvenky34
Participant
1540 Points
283 Posts
Re: how to add increment '1' in table column-
Oct 21, 2011 06:34 AM|LINK
hi,
Maintain one column in database table as no of views(as your chioce)
when every time clicked update table
i think it wil help you
Venkatesh.Gudipati
Please remember to click “Mark as Answer” on the post that helps you
munirah-mali...
Member
83 Points
111 Posts
Re: how to add increment '1' in table column-
Oct 21, 2011 06:37 AM|LINK
My problem is i dont know how to update the table. the syntax.
munirah-mali...
Member
83 Points
111 Posts
Re: how to add increment '1' in table column-
Oct 21, 2011 06:59 AM|LINK
Dim connectionString As String = ConfigurationManager.ConnectionStrings("SecurityTutorialsConnectionString").ConnectionString Dim updateSql As String = "UPDATE personnelrequisition SET TotalResume=@TotalResume WHERE PRNo=@PrNo" Using myConnection As New SqlConnection(connectionString) myConnection.Open() Dim myCommand2 As New SqlCommand(updateSql, myConnection) myCommand2.Parameters.AddWithValue("@PRNo", DropDownList1.SelectedValue()) myCommand2.Parameters.AddWithValue("@TotalResume", +1) myCommand2.ExecuteNonQuery() myConnection.Close() End UsingPlease see line myCommand2.Parameters.AddWithValue("@TotalResume", +1), i dont know how to write increment 1, how? anyone can help?
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: how to add increment '1' in table column-
Oct 23, 2011 12:42 AM|LINK
Hello munirah-malik:)
You can just use this bysetting the column increamented by 1, like this below:
Dim connectionString As String = ConfigurationManager.ConnectionStrings("SecurityTutorialsConnectionString").ConnectionString
Dim updateSql As String = "UPDATE personnelrequisition SET TotalResume=TotalResume+1 WHERE PRNo=@PrNo"
Using myConnection As New SqlConnection(connectionString)
myConnection.Open()
Dim myCommand2 As New SqlCommand(updateSql, myConnection)
myCommand2.Parameters.AddWithValue("@PRNo", DropDownList1.SelectedValue())
myCommand2.ExecuteNonQuery()
myConnection.Close()
End Using
hans_v
All-Star
35986 Points
6550 Posts
Re: how to add increment '1' in table column-
Oct 23, 2011 12:48 AM|LINK
Do you mean that you want to know how many records you have in this table? if so storing this value in the database isn't good practice, you can get it simply like this:
SELECT COUNT(*) FROM personnelrequisition