Hi Marcin!
Thanks for the hint! In the meantime I found the information in the msdn
documentation that ODBC does not support named parameters, so
this is important to know as the msdn examples does not use ODBC :)
Now my VB-Application can call the DBProc, but I have a new
'problem'.
This is the definition of the DBProc:
-------------------------------------
CREATE DBPROC WWIND.BESTELLUNGNEU (IN KDNR FIXED(10), OUT BESTNR FIXED(10))
AS
VAR KDFIRMA CHAR(40); KDSTRASSE CHAR(60); KDORT CHAR(15);
KDREGION CHAR(15); KDPLZ CHAR(10); KDLAND CHAR(15);
LRC INTEGER;
TRY
SUBTRANS BEGIN;
SELECT FIRMA, STRASSE, ORT, REGION, PLZ, LAND
FROM WWIND.KUNDEN
WHERE KUNDENNR = :KDNR;
FETCH INTO :KDFIRMA, :KDSTRASSE, :KDORT,
:KDREGION, :KDPLZ, :KDLAND;
LOCK (WAIT) TABLE WWIND.BESTELLUNGEN IN EXCLUSIVE MODE;
INSERT INTO WWIND.BESTELLUNGEN
(KUNDENNR, PERSONALNR, BESTELLDATUM,
VERSANDUEBER, EMPFAENGER, STRASSE,
ORT, REGION, PLZ, BESTIMMUNGSLAND)
VALUES
(:KDNR, 10, CURDATE(), 1, :KDFIRMA, :KDSTRASSE,
:KDORT, :KDREGION, :KDPLZ, :KDLAND);
SELECT WWIND.BESTELLUNGEN.CURRVAL FROM DBADMIN.DUAL;
FETCH INTO :BESTNR;
CATCH
BEGIN
SET LRC = $RC;
SUBTRANS ROLLBACK;
STOP (LRC, 'Ein Fehler verhinderte die Anlage der Bestellung');
END;
SUBTRANS END;
This VB-Codes calls the DBProc:
-------------------------------
Private Sub Form3_Load(ByVal sender As ...
Cursor.Current = Windows.Forms.Cursors.WaitCursor
Button1.Enabled = False
Label4.Text = strKdNr
Label3.Text = strKdFirma
cn.ConnectionString = strConn
Try
cn.Open()
With cmd
.Connection = cn
.CommandType = CommandType.StoredProcedure
.CommandText = "CALL WWIND.BESTELLUNGNEU (" & strKdNr & ", ?)"
.Parameters.Add("", Odbc.OdbcType.Int).Direction =
ParameterDirection.Output
.ExecuteNonQuery()
End With
cn.Close()
Label12.Text = cmd.Parameters.Item(0).Value.ToString
DataGrid1.CaptionText = "Bestellnr. " & Label12.Text
Catch ex As Exception
If cn.State = ConnectionState.Open Then
cn.Close()
End If
MessageBox.Show("Ein Fehler...")
Finally
Cursor.Current = Windows.Forms.Cursors.Default
End Try
End Sub
And here is my problem on that:
Opening Form3 calls the DBProc and this seems to work fine,
but for any reason only every second sequence-number is set by the
DBMS when calling the procedure by the VB-Application. This number is
variable BESTNR in the DBProc.
When calling the procedure in the SQL Studio by
"CALL WWIND.BESTELLUNGNEU(1, :x)"
the DBMS sets every Number as expected.
Have anyone an explanation on that?
Thanks for help and comments!
Regards
> **************************************************************
> Hello,
> Yes, the MSDN docs aren't clear here - it's true.
> I can't see anything wrong with parameters, however,
> there IS something wrong with your command text.
> You should change it to the:
> .Commandtext = "CALL WWIND.BESTELLUNGNEU(?,?)"
> One question mark should be provided for every parametr of sp.
> At least, this is how it works on my side.
> Good luck!
>
> Marcin Pytel
--
10 GB Mailbox, 100 FreeSMS/Monat http://www.gmx.net/de/go/topmail
+++ GMX - die erste Adresse für Mail, Message, More +++
--
MaxDB Discussion Mailing List
For list archives: http://lists.mysql.com/maxdb
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]