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 April 22nd, 2005, 04:38 AM
Authorized User
 
Join Date: Nov 2004
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default OIeDbCommand and Session Question

what wrong with the following code, as I can't find any error and the syntax seem true
note:
every variable in session are string type
Code:
        dim cn as new oledbconnection(application("cnStr"))
        dim sql as string="update users set bgcolor=@bgcolor,fontcolor=@fontcolor,visited=@visited,alink=@alink where login_id=@login_id"
        dim cmd as new oledbcommand(sql,cn)
        cmd.parameters.add(new oledbparameter("@bgcolor",oledbtype.char,10))
        cmd.parameters("@bgcolor").value=session("bgcolor")
        cmd.parameters.add(new oledbparameter("@fontcolor",oledbtype.char,10))
        cmd.parameters("@fontcolor").value=session("fontcolor")
        cmd.parameters.add(new oledbparameter("@visited",oledbtype.char,10))
        cmd.parameters("@visited").value=session("visited")
        cmd.parameters.add(new oledbparameter("@alink",oledbtype.char,10))
        cmd.parameters("@alink").value=session("alink")

        cmd.parameters.add(new oledbparameter("@login_id",oledbtype.char,19))
        cmd.parameters("@login_id").value=session("userid")

        try
            cn.open()
            cmd=new oledbcommand(sql,cn)
            cmd.executeNonQuery()
        catch ex as exception
            response.write(ex.toString())
        Finally
            cn.dispose()
            session.abandon
        end try

System.Data.OleDb.OleDbException: No value given for one or more required parameters. at System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(Int32 hr) at System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteNonQuery() at ASP.Logout_aspx.page_load(Object sender, EventArgs e) in D:\IP2\logout.aspx:line 48

For question asking, please made sure that your question is as similar as possible while providing enought level of details!
Since not all peoples, like to read large amounts of text just for reading or requirement and waste the answer time to read your text
__________________
For question asking, please made sure that your question is as similar as possible while providing enought level of details!
Since not all peoples, like to read large amounts of text just for reading or requirement and waste the answer time to read your text
 
Old April 22nd, 2005, 09:51 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Could you please tell us what the problem is that you are having? I'm not going to read all your code and then try to guess what's wrong with it. If you are getting an error please post it.

-Peter
 
Old April 23rd, 2005, 06:51 AM
Authorized User
 
Join Date: Nov 2004
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

it generate this error:
System.Data.OleDb.OleDbException: No value given for one or more required parameters. at System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(Int32 hr) at System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteNonQuery() at ASP.Logout_aspx.page_load(Object sender, EventArgs e) in D:\IP2\logout.aspx:line 48

For question asking, please made sure that your question is as similar as possible while providing enought level of details!
Since not all peoples, like to read large amounts of text just for reading or requirement and waste the answer time to read your text
 
Old April 23rd, 2005, 02:23 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

All your parameters are there, so it looks like there's a problem with the values coming from the session. If one of those is Nothing/Null then the parameter will be empty which would trigger this error.
 
Old April 23rd, 2005, 09:15 PM
Authorized User
 
Join Date: Nov 2004
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by planoie
 All your parameters are there, so it looks like there's a problem with the values coming from the session.?If one of those is Nothing/Null then the parameter will be empty which would trigger this error.
Thanks for your suggestion.

So I added some code to the catch part in order to show that the existent of values in session

And confirmed all of them contain values

For question asking, please made sure that your question is as similar as possible while providing enought level of details!
Since not all peoples, like to read large amounts of text just for reading or requirement and waste the answer time to read your text





Similar Threads
Thread Thread Starter Forum Replies Last Post
Cookieless Session Question dparsons ASP.NET 2.0 Professional 4 April 2nd, 2007 03:47 AM
2nd chapter session question infernon BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 March 14th, 2007 12:07 PM
Frameset and Session State Question IS_Princess Classic ASP Professional 0 April 6th, 2005 09:11 AM
simple session question cygnusx04 Classic ASP Basics 2 October 21st, 2004 08:50 AM





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