Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
| 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 November 20th, 2003, 09:36 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Portsmouth, Hampshire, United Kingdom.
Posts: 146
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to aadz5
Default Syntax for OleDb Command Object Parameters

Is this syntax correct I keep getting this error: -

Exception Details: System.Data.OleDb.OleDbException: No value given for one or more required parameters.

here is my code: -


String strAuthor = Author.Text;
String strTitle = Title.Text;

String strSearch = String.Format("SELECT * FROM Computing WHERE BookAuthor LIKE '{0}' OR BookName LIKE '{1}'", strAuthor, strTitle);

OleDbCommand objCommand = new OleDbCommand();
OleDbDataReader objDataReader = null;

Connect();
       objCommand.Connection = objConnection;
       objCommand.CommandType = CommandType.Text;
       objCommand.CommandText = "Select * FROM Computing Where BookAuthor = ? AND BookTitle = ?";
       objCommand.Parameters.Add("BookAuthor", OleDbType.VarChar, 32,"BookAuthor");
       objCommand.Parameters.Add("BookName", OleDbType.VarChar, 128, "BookName");

       objCommand.Parameters["BookAuthor"].Value = Author.Text;
       objCommand.Parameters["BookName"].Value = Title.Text;
       objDataReader = objCommand.ExecuteReader();


if (objDataReader.Read())
{
         //dgComputing.DataSource = objDataReader;
         //dgComputing.DataBind();
}
objDataReader.Close();
Disconnect();


Adz - Portsmouth Massive
__________________
Adz - Learning The J2EE Ways.
 
Old November 20th, 2003, 11:53 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Found this article on MSDN, it has some useful information that may help you out.

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old November 20th, 2003, 01:53 PM
Friend of Wrox
 
Join Date: Oct 2003
Location: Portsmouth, Hampshire, United Kingdom.
Posts: 146
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to aadz5
Default

Peter,

thanks, this article is a help with regards to writting my select statement for the commandtext property but I want some information on how to use the command. parameters.Add(.....) attribute how to code it, I cant seem to find anything on the net for it as well. Its can get frustrating. Any ideas

Adz - Portsmouth Massive
 
Old November 20th, 2003, 02:12 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

If you follow the right links in that article you should be able to get all the syntax assistant you need. For example... you could click on OleDbParameterCollection, then OleDbParameterCollection Members, then Add where you could find all the overloaded version of the Add method in 4 different languages.

I could go on...

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old November 20th, 2003, 03:31 PM
Friend of Wrox
 
Join Date: Oct 2003
Location: Portsmouth, Hampshire, United Kingdom.
Posts: 146
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to aadz5
Default

Thank you Peter,

Just need to look harder I guess, it shows all the examples I need. You star, thank you very much for your help. :)

Adz - Portsmouth Massive




Similar Threads
Thread Thread Starter Forum Replies Last Post
How to update Recordset using oledb.command jmhemadri Classic ASP Databases 5 September 11th, 2008 03:46 PM
Issues with Command Object and Parameters BSkelding Crystal Reports 0 May 2nd, 2007 10:29 AM
trouble w/ command object and parameters RbH All Other Wrox Books 0 August 5th, 2003 12:31 PM





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