Solved

Problems using running stored procedures via VBA

Posted on 2004-03-24
2
174 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now