Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 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 12th, 2006, 08:13 AM
Registered User
 
Join Date: May 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default SP Returns Nothing but runs fine...help

I am using SQL 2000 (edition installed with SBS2003 Premium) and converted an Access Database application to an .adp file. We are using Access 2003 to develop the .adp.

My issue is working with stored procedures. I created a stored procedure that works fine in Query Analyzer. For reference here it is:

CREATE PROCEDURE dbo.usp_ShowAllBetweenDates (@dtStartDate As DateTime, @dtEndDate As DateTime)
As
SELECT dbo.tblComments.chrSubjectType, dbo.tblComments.chrSubject, dbo.tblComments.chrUser, dbo.tblComments.dtmDateEnt,
                      dbo.tblComments.intHeadingID AS HeadingID, dbo.tblComments.intDoorID, dbo.tblDoors.chrDoorNr AS chrDoorN, dbo.tblHeadings.chrHeadingNr,
                      dbo.tblHeadings.intProjID, dbo.tblHeadings.chrH_Flag, dbo.tblDoors.chrD_Flag, dbo.tblComments.CommentsID, dbo.tblHeadings.chrH_Flag2,
                      dbo.tblDoors.chrD_Flag2
FROM dbo.tblComments INNER JOIN
                      dbo.tblHeadings ON dbo.tblComments.intHeadingID = dbo.tblHeadings.HeadingID INNER JOIN
                      dbo.tblDoors ON dbo.tblComments.intDoorID = dbo.tblDoors.DoorID AND dbo.tblHeadings.HeadingID = dbo.tblDoors.intHeadingID
WHERE (dbo.tblHeadings.chrHeadingNr <> N'Global') AND (dbo.tblHeadings.chrHeadingNr <> N'Schedule') AND (dbo.tblComments.dtmDateEnt >= @dtStartDate) AND
  (dbo.tblComments.dtmDateEnt <= @dtEndDate)
GO

I wrorte the following code in the .adp project which runs when the form loads that the data is supposed to populate into the form (that is what I would like it to do):

Private Sub Form_Load()

    Dim cnn As New ADODB.Connection
    Dim cmd As New ADODB.Command
    Dim param1 As ADODB.Parameter, parama2 As ADODB.Parameter

    Dim dtStartDateH As Date
    Dim dtEndDateH As Date

    dtStartDateH = Forms![frmMain]![txtSortStartDate]
    dtEndDateH = Forms![frmMain]![txtSortEndDate]

    Set cnn = CurrentProject.Connection

    Set cmd.ActiveConnection = cnn

    cmd.CommandText = "dbo.usp_ShowAllBetweenDates"
    cmd.CommandType = adCmdStoredProc

    Set param1 = cmd.CreateParameter("@dtStartDate", adDBDate, adParamInput)
    cmd.Parameters.Append param1
    param1.Value = dtStartDateH
    Set param2 = cmd.CreateParameter("@dtEndDate", adDBDate, adParamInput)
    cmd.Parameters.Append param2
    param2.Value = dtEndDateH

    cmd.Execute

It seems to run fine as I get no errors. However when the form loads I get the typical '#Name?' showing up in all my form boxes. The form label names all match the names in the stored procedure. If I use the Stored Procedure as the record source and manually enter the dates the form populates perfectly. It is just when I am trying to pass data through the VB code that nothing happens. I checked the security and the Stored Procedure has the correct Execute permisions.

Can anyone tell me what I doing wrong? Any help would be greatly appreciated.

Thanks,

Chris


 
Old May 15th, 2006, 05:55 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 246
Thanks: 0
Thanked 0 Times in 0 Posts
Default

At which line of code does the "#Name?" occur?






Similar Threads
Thread Thread Starter Forum Replies Last Post
Fine Tunning a Program ToniDe Java Basics 0 October 19th, 2006 12:59 AM
code behind fine missing CHen VS.NET 2002/2003 0 March 4th, 2005 03:25 PM
exec sp within another sp collie SQL Server 2000 1 December 22nd, 2004 05:46 AM
Can a SP run another SP as sa? dbradley SQL Server 2000 0 July 17th, 2003 08:35 AM





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