Solved

Problems using running stored procedures via VBA

Posted on 2004-03-24
2
180 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month6 days, 19 hours left to enroll

623 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