Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 1.1
This is the forum to discuss the Wrox book Beginning ASP.NET 1.1 with Visual C#.NET 2003 by Chris Ullman, John Kauffman, Chris Hart, Dave Sussman, Daniel Maharry; ISBN: 9780764557088
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning 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 May 9th, 2005, 07:00 AM
Registered User
 
Join Date: May 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default PLS HELp URGENT !

I am adapting the calendar on chapter 10 of the book . i am using oledb nand i am getting an error;

Exception Details: System.Data.OleDb.OleDbException: Must declare the variable '@Date'.

Source Error:


Line 52:
Line 53: dbConnection.Open()
Line 54: Dim dataReader As System.Data.IDataReader = dbCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)
Line 55: Return dataReader


Below is the function that should actually pass the parameter @Date

==========
 Function EventsByDate(ByVal [_date] As Date) As System.Data.IDataReader
        Dim connectionString As String = "Provider=SQLOLEDB;workstation id=SPC3;packet size=4096;user id=sa;data source=localhost;persist sec" & _
        "urity info=True;initial catalog=hav_extranet;password=christ"

        Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString )
        Dim queryString As String = "SELECT id, _date, starttime, endtime, title, audience, type, contact FROM hav_events WHERE (_date = @Date)"

        Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
        dbCommand.CommandText = queryString
        dbCommand.Connection = dbConnection

        Dim dbParam_date As System.Data.IDbDataParameter = New System.Data.OleDb.OleDbParameter
        dbParam_date.ParameterName = "@Date"
        dbParam_date.Value = [_date]
        dbParam_date.DbType = System.Data.DbType.DateTime
        dbCommand.Parameters.Add(dbParam_date)

        dbConnection.Open()
        Dim dataReader As System.Data.IDataReader = dbCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)
        Return dataReader


    End Function
===============

  _date is the date column in the database

Thanks a million!

 
Old May 10th, 2005, 12:12 AM
Friend of Wrox
 
Join Date: Apr 2005
Posts: 186
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

The problem is you are using oledbprovider and connecting to SQl Server.
I donot mean that you cannot do it. You can, but when you specify parameters use "?" in the query and put some name without '@' as parametername (only the order of parameters is important).


FROM hav_events WHERE (_date = ?)

dbParam_date.ParameterName = "MyDate"

Prashant










Similar Threads
Thread Thread Starter Forum Replies Last Post
Can any one help me pls Urgent..? venkatu2005 ASP.NET 1.0 and 1.1 Basics 1 April 8th, 2008 08:45 AM
IFRAMES ...... PLS URGENT raaj Beginning PHP 1 February 28th, 2007 03:39 PM
PHP with IFRAME..pls help me its URGENT raaj Beginning PHP 2 February 26th, 2007 03:12 AM
datagrid problem urgent pls. dsmportal Pro VB.NET 2002/2003 0 February 7th, 2005 09:00 PM
Urgent, Can someone pls explain ? vanjamier Pro JSP 0 December 10th, 2004 02:32 AM





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