Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 February 24th, 2004, 12:49 PM
Authorized User
 
Join Date: Feb 2004
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default not able to update the table..

Hi. friends

I am usind the following code to update the table.
this event occure when the submit button hits.

Sub submit_Click(ByVal sender As Object, ByVal e As ImageClickEventArgs)


             Dim strSQL As String
             Dim strStuID As String



             Dim Cookie as HttpCookie = Request.Cookies("dashUser")


             strSQL = "UPDATE alt_ed_attendance SET ATTEND_RSN= " & txtReason.SelectedItem.Value & " WHERE permnum = " & strStuID & " "



                'Dim myConnection As OleDbConnection = New OleDbConnection("PROVIDER=MSDAORA.1;Password="";Us er ID="";Data Source="";Persist Security Info=true")
               'Dim myCommand As OleDbDataAdapter = New OleDbDataAdapter(strSQL, myConnection)
               'Dim mybuild as OleDbCommandBuilder= new OleDbCommandBuilder(myCommand)
               'myCommand.updateCommand = mybuild.GetUpdateCommand()



                Dim myConnection As OleDbConnection = New OleDbConnection("PROVIDER=MSDAORA.1;Password="";Us er ID="";Data Source="";Persist Security Info=true")
                Dim myCommand As OleDbCommand = New OleDbCommand(strSQL, myConnection)
                Dim result

                Try
                    myConnection.Open()
                    result = myCommand.ExecuteNonQuery




                Catch err as Exception

                Finally
                  If (Not myConnection is Nothing) Then


                     myConnection.Close()
                     Response.Redirect ("data_taft1.aspx")
                  End If
                End Try


    end Sub



if anybody can guide me please .....


Aashish Shah
__________________
Aashish Shah
 
Old February 24th, 2004, 01:13 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What data type is the field ATTEND_RSN? Unless it's a numeric field you'll need to wrap the value in single quotes. Or you could use the parameters collection of the command class.

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old February 24th, 2004, 01:18 PM
Authorized User
 
Join Date: Feb 2004
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks peter..

it is string .. if have also tried it with wraping it in a single quotes too.. I have tried both the method of connection to data base.
but not able to understand that what is the problem..
did i coded wrong for update query or what ...
I dont understand .. can you help me out for this problme .. It will be grate help of yours... thanks
aashish

Aashish Shah
 
Old February 24th, 2004, 01:21 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What is the actual error you are getting?
 
Old February 24th, 2004, 01:29 PM
Authorized User
 
Join Date: Feb 2004
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default

error is not comming out.. but when I am checking the table when I am running query in PLSQL the data is not there..


thats the problem.. thanks
aashish

Aashish Shah
 
Old February 24th, 2004, 02:17 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Try
                    myConnection.Open()
                    result = myCommand.ExecuteNonQuery




                Catch err as Exception
                    response.write(err.message)
                Finally
                  If (Not myConnection is Nothing) Then


                     myConnection.Close()
                     Response.Redirect ("data_taft1.aspx")
                  End If
                End Try


 
Old February 24th, 2004, 02:24 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Also here is how you can use ado.net to update:

strSQLQuery = "UPDATE [table_name] SET [column_name1]=@YourNamedParameter1, [column_name2]=@YourNamedParameter2 WHERE ([table_name].[id] = 1)"

        objCommand = New OleDbCommand(strSQLQuery, objConn)

        objCommand.Parameters.Add(New OleDbParameter("@YourNamedParameter1", OleDbType.Date, 25))
        objCommand.Parameters("@YourNamedParameter1").Valu e = now()

        objCommand.Parameters.Add(New OleDbParameter("@YourNamedParameter2", OleDbType.Char, 100))
        objCommand.Parameters("@YourNamedParameter2").Valu e = txtEvent.Text

        objConn.Open()
        objCommand.ExecuteNonQuery()
        objConn.Close()
 
Old February 24th, 2004, 04:11 PM
Authorized User
 
Join Date: Feb 2004
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks
with the ado.net it work out.. thanks


Aashish Shah





Similar Threads
Thread Thread Starter Forum Replies Last Post
update table from another db table timbal25 SQL Server 2005 3 January 19th, 2008 06:47 AM
Update one table to another table using DTS in SQL Printmaker SQL Language 0 July 24th, 2007 07:17 AM
How to Update one table with other table data? ramk_1978 SQL Language 2 May 26th, 2006 12:51 AM
update table with an ID Num from different table scoobie PHP How-To 12 January 25th, 2005 12:28 PM
Update parent table with the sum of child table gbrown SQL Language 2 November 9th, 2004 07:53 AM





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