Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Problems using running stored procedures via VBA

Posted on 2004-03-24
2
Medium Priority
?
184 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 2000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

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…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

971 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