Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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!

  #2 (permalink)  
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
  #3 (permalink)  
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

  #4 (permalink)  
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

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 01:06 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.