Solved

Problems using running stored procedures via VBA

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…

739 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