Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 28th, 2006, 07:13 AM
Authorized User
 
Join Date: May 2006
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default Update not working...

What could be wrong on my function=

    Sub MyDataList_Update(Sender As Object, E As DataListCommandEventArgs)

    Dim Conn as OleDbConnection
    Dim edit_price as string
        Dim EditText As HtmlInputText
        Dim MyConnection as String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("bd1.mdb") & ";"
        Dim SQL as String = "update Tabela set numero='" & edit_price & "' Where nome=@nome"
    Dim Cmd as OleDbCommand

        EditText = E.Item.FindControl("edit_price")
    conn = New OleDbConnection(MyConnection)
    Cmd = New OleDbCommand(SQL, conn)
    Cmd.Parameters.Add(New OleDbParameter("@numero", "edit_price"))

    Conn.Open()
    cmd.ExecuteNonQuery()
    Conn.close
        MyDataList.EditItemIndex = -1
        Message.InnerHtml = "Price Updated: " & EditText.Value
        PopulateList()
    End Sub

Please help!

 
Old June 28th, 2006, 09:43 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there..

first of all use a try catch construction in the executenonquery to receive an error and be able to correct it faster ;)

secodn, you have a parameter named @nome but you are passing the parameter @numero to the query...

HTH

Gonzalo
 
Old June 29th, 2006, 04:08 AM
Authorized User
 
Join Date: May 2006
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanx fot replying.
With all the changes I've been trying some code was missing there:


Dim SQL as String = "update Tabela set numero=@numero Where nome=@nome"
Dim Cmd as OleDbCommand

EditText = E.Item.FindControl("edit_price")
conn = New OleDbConnection(MyConnection)
Cmd = New OleDbCommand(SQL, conn)
Cmd.Parameters.Add(New OleDbParameter("@numero", "edit_price"))
Cmd.Parameters.Add(New OleDbParameter("@nome", "Nome"))
                                                ^====
I think the problem must be here:
I want to change @numero and I want to keep @nome
and I don't know what code shall I use to keep @nome

Ghozt

 
Old June 30th, 2006, 03:28 AM
Authorized User
 
Join Date: May 2006
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The code I posted is a conversion from a Datagrid.
With Datagrid it works but not with Datalist.
The main change and where I think the source of the problem is is on this line of code:

(datagrid)
  MyCommand.Parameters.Add(New OleDbParameter("@EmpID", e.Item.Cells(1).Text ))

I don't know how to convert it to Datalist.
Can someone help me?

Ghozt





Similar Threads
Thread Thread Starter Forum Replies Last Post
DetailsView update not working. Andrew.Berry ASP.NET 2.0 Professional 6 April 22nd, 2008 11:23 AM
Update Query Not Working Odifius BOOK: Beginning Access VBA 0 September 20th, 2006 11:33 AM
Update Code Not Working Odifius BOOK: Beginning Access VBA 0 September 19th, 2006 04:04 PM
UPDATE query is not working Sujit Joshi Beginning PHP 1 July 6th, 2005 04:07 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.