Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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 Display Modes
  #1 (permalink)  
Old May 9th, 2005, 07:00 AM
Registered User
Join Date: May 2005
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts

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

        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!

Reply With Quote
  #2 (permalink)  
Old May 10th, 2005, 12:12 AM
Friend of Wrox
Join Date: Apr 2005
Location: Cochin, , India.
Posts: 186
Thanks: 0
Thanked 0 Times in 0 Posts


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"


Reply With Quote

Thread Tools
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
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 02:39 PM
PHP with IFRAME..pls help me its URGENT raaj Beginning PHP 2 February 26th, 2007 02:12 AM
datagrid problem urgent pls. dsmportal Pro VB.NET 2002/2003 0 February 7th, 2005 08:00 PM
Urgent, Can someone pls explain ? vanjamier Pro JSP 0 December 10th, 2004 01:32 AM

All times are GMT -4. The time now is 01:42 PM.

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