Solved

Problems using running stored procedures via VBA

Posted on 2004-03-24
2
176 Views
Last Modified: 2012-05-04
Hi There,

I have a little vba script that checks for certain emails and then updates a SQL database via a stored procedure. The stored procedure works fine from query analyser but if I run it from VBA it miss's out a single field in the middle. I have run through the script step by step and it does have the field filled out at the execute stage. Here is the section that does the business:

    Dim Conn1 As ADODB.Connection
    Dim sConnect As String

    sConnect = "PROVIDER=MSDASQL;DSN=SQL2000;UID=username;PWD=password;"
   
    Set Conn1 = New ADODB.Connection
    Conn1.ConnectionString = sConnect
    Conn1.Open

        SQLString = "update_and_close @Callref = '" & _
            CallRef & "', @LTXRef = '" & LTXRef & "', @Arrival = '" _
            & fsrArrival & "', @Complete = '" _
            & fsrComplete & "', @Status = " & fsrStatus & _
            ", @Repair = " & fsrRepair & ", @FSRSolution = '" & RTrim(FSRSolution) & "'" _
            & ", @Dtime = " & compDtime

    Dim Cmd1 As ADODB.Command
    Set Cmd1 = New ADODB.Command
    Conn1.Execute SQLString

The field that is not going through is the @complete, however @arrival does which is setup the same as far as I can see. The definition of the variables is next;

Dim FSRSolution, CallRef, LTXRef, SQLString, fsrStatus As String
Dim strCallCoverCode, fsrArrival, fsrComplete As String
Dim fsrRepair As Integer
Dim compDtime As Double

CREATE PROCEDURE Update_And_Close
   @CallRef integer,
   @LTXRef integer,
   @Arrival varchar(20),
   @Complete varchar(20),
   @Status varchar(4),
   @Repair integer,
   @FSRSolution varchar(255),
   @Dtime float
AS

The arrival and complete fields were dates but I kept having problems converting them across so that may be part of the problem. Any help appreciated. Points at 500 as this is both urgent and extremely frustrating to me.
0
Comment
Question by:Gryff
2 Comments
 
LVL 7

Accepted Solution

by:
ramesh12 earned 500 total points
ID: 10669707
Cast or convert to date datatype dates with in stored procedure
0
 

Author Comment

by:Gryff
ID: 10675359
Did the job nicely, thanks.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question