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 1564
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: 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,...
| |
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,...
|
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...
|
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...
|
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...
|
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,...
|
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...
| |
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...
|
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 ...
| |