Re: Edit records and UPDATE statements

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Thank you for replying.

e is System.Web.UI.WebControls.DataGridCommandEventArgs as it is in the
procedure name: private void updateRow(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)

The connection string is in the web.config file and connects to the sql
server with the provided login.

The SQL string is:
dataCommand.CommandText = "SELECT GEM.customers.cust_id, " +
"GEM.customers.CustomerSince AS [Customer Since], " +
"GEM.customers.name AS [Insititution Name], " +
"GEM.contacts.name_first AS [First Name], " +
"GEM.contacts.name_last AS [Last Name], " +
"GEM.contacts.email AS [E-Mail Address], " +
"GEM.customers.address_1 AS Address, GEM.customers.city AS City, " +
"GEM.customers.state AS State, GEM.customers.zip_code AS [Zip Code], " +
"GEM.customers.postal_code AS [Postal Code], " +
"GEM.customers.country AS Country, GEM.customers.phone AS Phone " +
"FROM GEM.customers INNER JOIN GEM.config_usernames ON " +
"GEM.customers.cust_id = GEM.config_usernames.cust_id INNER JOIN " +
"GEM.contacts ON GEM.config_usernames.contact_id =
GEM.contacts.contact_id ORDER BY GEM.customers.name";

So, my understanding is that cell[6] as you see it in the UPDATE statement
refers to the GEM.customers.name column.


"gmiley" wrote:

First, I would suggest that you handle your Command string building a
bit differently. As you have it right now, I have no clue what
e.Item.Cells[6] is, other than it possibly being a control of some
kind.

I would suggest to help narrow down where the error might be, break
that all up to look like this:

object cell = e.Item.Cells[6];
TextBox txtBox = (TextBox)cell.Controls[0];
string nameValue = txtBox.Text;

That still is a bit goofy. Can you provide me with what those things
are?

What is 'e' and what is its Type?
What is 'Item' and what is its Type?
What is 'Cells' and what is its Type?

Something in there isn't right.

gm

Antonio wrote:
When I try to update a record, I get:

Specified argument was out of the range of valid values. Parameter name:
index

Exception Details: System.ArgumentOutOfRangeException: Specified argument
was out of the range of valid values. Parameter name: index

Source Error:

Line 133: SqlCommand updCommand = new SqlCommand();
Line 134: updCommand.Connection = conn;
Line 135: updCommand.CommandText = "UPDATE GEM.customers SET name = '"
Line 136: + ((TextBox)e.Item.Cells[6].Controls[0]).Text
Line 137: + "', address = '"

and the UPDATE line is selected. Can someone tell me what the error means?

Thanks,


Antonio


.



Relevant Pages

  • Re: Error message on assignment line before rs.update
    ... TenderType as string ... as to what an Update statement would look like based on the Query. ...
    (microsoft.public.vb.database.ado)
  • Re: Forms and ODBC connections
    ... Thank you for your answer but it isn't clear to me the sintax you are using ... for the connection string and the update statement. ... > and the connection string mirrored that of my linked tables. ...
    (microsoft.public.access.formscoding)
  • Re: how to modify an xml field that may be plain text
    ... The update statement in a stored procedure and is actually designed to update any or all fields in the table. ... cases where the field is not an xml fragment but just a string. ... or it could just be this 'blah blah blah'. ... So when updating this field it might need to update just one of the nodes or the entire field (in the case where it's a simple string). ...
    (microsoft.public.sqlserver.xml)
  • Re: Oracle Stored Proc issues
    ... I use the value in the update statement. ... G Quesnel wrote: ... declare the text variable to be some extra large number, ... string of text to the variable, then the variable will only contain ...
    (comp.databases.oracle.misc)
  • Re: Two columns have data mixed up need to fix
    ... How do you distingush whether a string value is a "Part Number" or a "name"? ... you can come up with an SQL predicate & use it in ... an UPDATE statement like: ...
    (microsoft.public.sqlserver.programming)