473,398 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

How to change the data of the selected rows on grid?

Hi, i currently has this code. When on click on the "Approve" button, the database of all the rows will change. I have "Approve" button on every row. How do i make it so that only the selected rows will change? Pls help. Thank in advance.

Sub CustomersGridView_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)


Dim str As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & Server.MapPath("database\db1.mdb")
Dim row As GridViewRow = GridView1.SelectedRow

If e.CommandName = "Approve" Then


'Dim index As Integer
Dim mySelectQuery As String = "SELECT State, FileID FROM Table3"

Dim myUpdateQuery As String = "Update Table3 Set State='6' "

Dim myConnection As New OleDbConnection(str)

Dim myCommand As New OleDbCommand(mySelectQuery, myConnection)

Dim myCommand2 As New OleDbCommand(myUpdateQuery, myConnection)

Dim retvalue As Integer

myConnection.Open()

myCommand2.ExecuteNonQuery()

Console.WriteLine(retvalue)

Dim myReader As OleDbDataReader

myReader = myCommand.ExecuteReader()


While myReader.Read()

Label1.Text = ("Approve")

End While


myReader.Close()


myConnection.Close()
End If



End Sub

p.s I'm using vb 2005
Apr 30 '07 #1
2 1059
kenobewan
4,871 Expert 4TB
I believe that you need to use the id in your update query. HTH.
Apr 30 '07 #2
I believe that you need to use the id in your update query. HTH.
Hi, thanks for the reply. How do i use id? I'm actually still learning vb so there are a lot that i don't know. Can u kindly show me how to do it? Thanks.
Apr 30 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: hlam | last post by:
Help - Calculating the total of a column in a data grid -- when data grid is part of Master-Detail set-up I have setup a Master-Detail form using Visual Studio.Net. A ListBox is the (Master)...
2
by: Brian Mitchell | last post by:
Ok, I know this is an elementary question but I have a data grid that is bound to a data table and I can't seem to find a way to match the selected row in the grid with it's respective row in the...
1
by: David | last post by:
Under asp.net 2, if I define SqlDatasource and bind it to a grid, is selected data accessible in code? Eg. if I select s single row from the grid, can I go to the base data from the SqlDatasource...
0
by: Rasika WIJAYARATNE | last post by:
Hi everyone, I have two grid-views and I am trying to populate the data on gv2 based on the selection in gv1. However when a row is selected in gv1, it doesn't populate the gv2 with data. I have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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
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
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...
0
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
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,...
0
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...

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.