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
Dim MyCommand As SqlCommand
Dim strConn as string =
"SERVER=207.42.67.18;UID=sa;PWD=mystery;DATABASE=d bHandicapperArticles;"
Dim sport As textbox = E.Item.cells(2).Controls(0)
Dim articleheader As textbox = E.Item.cells(3).Controls(0)
Dim articletext As textbox = E.Item.cells(4).Controls(0)
Dim fpick As textbox = E.Item.cells(5).Controls(0)
Dim strUpdateStmt As String
strUpdateStmt =" UPDATE tblArticles SET" & _
" sport =@sport, articleheader =@articleheader, fpick =@fpick,
articletext = @articletext " & _
" WHERE articleID = @articleID"
conn = New SqlConnection(strConn)
MyCommand = New SqlCommand(strUpdateStmt, conn)
MyCommand.Parameters.Add(New SQLParameter("@sport", sport.text))
MyCommand.Parameters.Add(New SQLParameter("@articleheader",
articleheader.text))
MyCommand.Parameters.Add(New SQLParameter("@articletext",
articletext.text))
MyCommand.Parameters.Add(New SQLParameter("@fpick", fpick.text))
MyCommand.Parameters.Add(New SQLParameter("@articleID",
e.Item.Cells(1).Text ))
conn.Open()
MyCommand.ExecuteNonQuery()
MyDataGrid.EditItemIndex = -1
conn.close
BindData
End Sub
thanks in advance
chum 3 1560
Hi Chumley,
Is this OleDb add than the parameters in the sequence of your SQL string
(they are now not)?
I think that that will help?
Cor
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 Dim MyCommand As SqlCommand Dim strConn as string = "SERVER=207.42.67.18;UID=sa;PWD=mystery;DATABASE=d bHandicapperArticles;" Dim sport As textbox = E.Item.cells(2).Controls(0) Dim articleheader As textbox = E.Item.cells(3).Controls(0) Dim articletext As textbox = E.Item.cells(4).Controls(0) Dim fpick As textbox = E.Item.cells(5).Controls(0) Dim strUpdateStmt As String strUpdateStmt =" UPDATE tblArticles SET" & _ " sport =@sport, articleheader =@articleheader, fpick =@fpick, articletext = @articletext " & _ " WHERE articleID = @articleID" conn = New SqlConnection(strConn) MyCommand = New SqlCommand(strUpdateStmt, conn) MyCommand.Parameters.Add(New SQLParameter("@sport", sport.text)) MyCommand.Parameters.Add(New SQLParameter("@articleheader", articleheader.text)) MyCommand.Parameters.Add(New SQLParameter("@articletext", articletext.text)) MyCommand.Parameters.Add(New SQLParameter("@fpick", fpick.text)) MyCommand.Parameters.Add(New SQLParameter("@articleID", e.Item.Cells(1).Text )) conn.Open() MyCommand.ExecuteNonQuery() MyDataGrid.EditItemIndex = -1 conn.close BindData End Sub
thanks in advance chum
"Cor Ligthert" <no**********@planet.nl> wrote in message news:<#F**************@TK2MSFTNGP12.phx.gbl>... Hi Chumley,
Is this OleDb add than the parameters in the sequence of your SQL string (they are now not)?
I think that that will help?
No, I'm using the system.data.sqlclient classes:
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQLClient" %>
Hi Chumley,
I saw parameter and was focused on the Parameters.
Is there a special reason that you do not use something simple as?
Dim sporttext As string = E.Item.cells(2).text
MyCommand.Parameters.Add(New SQLParameter("@sport", sporttext))
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Gamze |
last post by:
Hi,
How can i get values from datagrid to combobox and should select the same
name as in datagrid row on the combobox control
In my vb.net windows application ,i have combobox which is...
|
by: Stan |
last post by:
This is how I access Pieces field in my editable datargid during Update
event:
protected void grdMain_OnUpdate(Object sender, DataGridCommandEventArgs e)
{
string Pieces = ((TextBox)...
|
by: Mark |
last post by:
Hi,
I have a datagrid with a column for the Edit, Update, Cancel links.
That worked fine.
Above the datagrid I then added a textbox, required field validator
and button so I could use that to...
|
by: D. Shane Fowlkes |
last post by:
I have a Datagrid which in theory, should allow you to edit and update the
records. I've stripped my test page down so that it's only attempting to
update one field - "description". Yet when I...
|
by: Wolffang |
last post by:
From: "Wolffang" <javid@techlite.co.uk>
Subject: How to do a multiple select and update in a datagrid
Date: 23 October 2004 21:28
Using Visual studio.net VB
I have a datagrid that brings...
|
by: Mok |
last post by:
Hello,
I want to pull information from a table in sql server, bind it to a
grid and update those values. I would like to know the best way to do
it. I used the configure data adapter wizard and it...
|
by: Larry Woods |
last post by:
I have a datagrid that is carrying all fields of a record...except one. Now
I want to update the underlying database via a dataadapter. The update is
working but the field that is "left out" is...
|
by: Reena |
last post by:
Hi,
Working with ASP.NET 2.0 with Masterpages.
Here is my datagrid...
<asp:DataGrid ID="dgSelectedFields" runat="server"
BorderStyle=None
GridLines="None"
CssClass="grdData"
|
by: juustagirl |
last post by:
There is only one editable field on my datagrid ... a combo box.
The data displays correctly. I have a button to make all the changes
.... but they are never written back to my Access database....
|
by: Sharon |
last post by:
Hello All,
Is it possible to update Sql Table through DataGrid. I have a DataGrid
which is being populated through a stored procedure, all i wanted to do
is to update one field...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |