473,657 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Update datagrid subroutine indexed item problem

I have an admin script to modify data in an Access db, but when I hit the
update button after changing a field, I get a "Specified argument was out of
the range of valid values. Parameter name: index" error at the line where
I'm declaring my 'phone' variable. This subroutine worked with another table
I was working with , but I'm wondering why the numerical assignment is
having problems.
Thanks in advance
Bill

''
Sub MyDataGrid_Upda teCommand(s As Object, e As DataGridCommand EventArgs )

Dim conn As OleDbConnection

Dim MyCommand As OleDbCommand

Dim strConn as string = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
Source=E:\web\m ydomain\db\mydb .mdb;"

Dim company As textbox = E.Item.cells(2) .Controls(0)

Dim address As textbox = E.Item.cells(3) .Controls(0)

Dim city As textbox = E.Item.Cells(4) .Controls(0)

Dim state As textbox = E.Item.cells(5) .Controls(0)

Dim county As textbox = E.Item.cells(6) .Controls(0)

Dim zip As textbox = E.Item.cells(7) .Controls(0)

Dim phone As textbox = E.Item.cells(8) .Controls(0)

Dim descript As textbox = E.Item.cells(9) .Controls(1)

Dim web As textbox = E.Item.cells(10 ).Controls(0)

Dim email As textbox = E.Item.cells(11 ).Controls(0)

Dim datesold As textbox = E.Item.cells(12 ).Controls(0)

Dim dateexpire As textbox = E.Item.cells(13 ).Controls(0)
Dim strUpdateStmt As String

strUpdateStmt =" UPDATE CPAs SET" & _

" company = @company, address = @address, city = @city, state = @state, " &
_

"county = @county, zip = @zip, phone = @phone, descript =@ descript, " & _

"web = @web, email = @email, datesold = @datesold, dateexpire = @dateexpire"
& _

" WHERE cpaID = @cpaID"

conn = New OleDbConnection (strConn)

MyCommand = New OleDbCommand(st rUpdateStmt, conn)

MyCommand.Param eters.Add(New OleDbParameter( "@company", company.text))

MyCommand.Param eters.Add(New OleDbParameter( "@address", address.text))

MyCommand.Param eters.Add(New OleDbParameter( "@city", city.text))

MyCommand.Param eters.Add(New OleDbParameter( "@state", state.text))

MyCommand.Param eters.Add(New OleDbParameter( "@county", county.text))

MyCommand.Param eters.Add(New OleDbParameter( "@zip", zip.text))

MyCommand.Param eters.Add(New OleDbParameter( "@phone", phone.text))

MyCommand.Param eters.Add(New OleDbParameter( "@descript" , descript.text))

MyCommand.Param eters.Add(New OleDbParameter( "@web", web.text))

MyCommand.Param eters.Add(New OleDbParameter( "@email", email.text))

MyCommand.Param eters.Add(New OleDbParameter( "@datesold" , datesold.text))

'', dateexpire =@dateexpire

MyCommand.Param eters.Add(New OleDbParameter( "@dateexpir e", dateexpire.text ))
MyCommand.Param eters.Add(New OleDbParameter( "@cpaID",
e.Item.Cells(1) .Text ))

conn.Open()

MyCommand.Execu teNonQuery()

MyDataGrid.Edit ItemIndex = -1

conn.close

BindData

End Sub

''
Sep 21 '06 #1
0 1208

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

Similar topics

3
1577
by: Chumley the Walrus | last post by:
Even tho all my field names are named right, I cannot figure why I am getting a "Specified argument was out of the range of valid values. Parameter name: index" error on the line that holds " Dim sport As textbox = E.Item.cells(2).Controls(0)". Below is the entire subroutine to update/edit data on the datagrid in use: Sub MyDataGrid_UpdateCommand(s As Object, e As DataGridCommandEventArgs ) Dim conn As SqlConnection
10
360
by: Brett | last post by:
Hello... Im having a problem getting a datagrid to update. Everything in my code looks ok so Im at a loss. I can click update and the grid will rebind... but not with my updated data. I am not posting back in pageload... And its not database permissions cause I can do inserts. Please Help! here is my code: Sub dgStaff_Update(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
7
1996
by: Scott Schluer | last post by:
Hi All, I have a functioning datagrid on "Page 1" that displays order information for a single order (this is for an e-commerce site). It's actually a combination of a couple datagrids to display all of the information. I now have a need to drop this datagrid into a repeater on "Page 2". The repeater will grab ALL orders within a given date range and output the datagrids for each order. Remember, the Page 1 is built to display one...
4
2968
by: David Colliver | last post by:
Hi all, I am having a slight problem that hopefully, someone can help me fix. I have a form on a page. Many items on the form have validation controls attached. Also on this form are linkbuttons which must not cause validation. I have found a setting "causeValidation" to disable the validation. Also on the page, I have a datagrid that I will edit lines on. I can click
1
1718
by: BW | last post by:
Hello, I am attempting to to take edited values from a datagrid control and update the underlying database. Problem is that some of the edited values don quite seem to make it to my update sub. My code is shown below. The values that are not appearing are Cell(4) - sCompletion and Cell(5) - sNote. The other values show up just fine. What am I missing here?
25
4054
by: Neo Geshel | last post by:
This works: <form> <asp:TextBox id="name" /> <%= name.ClientID %> </form> But this DOES NOT work: <form>
3
1821
by: Pat | last post by:
I have a 2 nested Datagrid. When i select a row in the Master Datagrid i populate the Child databrid using myDataGrid.SelectedIndex value as the filter and setting the DataKeyField. I enabled paging for the MasterDataGrid which works well but when i page to the next set of rows and select a particular ROW(for example SHOW DETAILS) to populated the Child Datagrid after paging to the next page it doesn't work.. it just sends me back to the...
13
2445
by: shookim | last post by:
I don't care how one suggests I do it, but I've been searching for days on how to implement this concept. I'm trying to use some kind of grid control (doesn't have to be a grid control, whatever works best) to display a dropdown menu of fields populated from table tblInvoiceData. This control also includes a textbox which the user can input a value. These two columns are side by side and not in a vertical layout. The user then clicks on...
10
2958
by: amiga500 | last post by:
Hello, I have one basic simple question. When I have multiple records in the datagrid as follows: Code Product 1 Product 2 Product 3 11111 A B C 22222 D E F 33333 G H I 44444 J K L
0
8306
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8825
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8503
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6164
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4152
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.