I have the following stored procedure in an sql database
------------------------------------
CREATE PROCEDURE zspQuoteSummary
@dStart DateTime,
@dEnd DateTime
AS
SELECT qtmast.fstatus,
qtmast.festimator,
qtmast.fcompany,
qtmast.fquoteno AS Quote,
qtmast.frevno AS Rev,
qtmast.fquotedate,
qtitem.fenumber AS ItemNumber,
qtitem.fpartno AS Part,
qtitem.fpartrev AS PartRev,
qtpest.fmatlcost + qtpest.ftoolcost + qtpest.flabcost + qtpest.fovhdcost +
qtpest.fsubcost + qtpest.fothrcost + qtpest.fsetupcost AS TotalCost,
qtitem.funetprice AS UnitPrice,
qtitem.festqty AS Qty,
qtitem.funetprice*qtitem.festqty AS Extended,
GM =
CASE
WHEN (qtitem.funetprice*qtitem.festqty) <> 0 THEN
((qtitem.funetprice*qtitem.festqty) - (qtpest.fmatlcost + qtpest.ftoolcost +
qtpest.flabcost + qtpest.fovhdcost + qtpest.fsubcost + qtpest.fothrcost +
qtpest.fsetupcost) )/(qtitem.funetprice*qtitem.festqty)
ELSE
0
END,
EAU =
CASE
WHEN SUBSTRING(qtitem.fdescmemo,1,4) = UPPER('EAU:') THEN
SUBSTRING(qtitem.fdescmemo,5,10)
ELSE
0
END,
EAUExtended =
CASE
WHEN SUBSTRING(qtitem.fdescmemo,1,4) = UPPER('EAU:') THEN
SUBSTRING(qtitem.fdescmemo,5,10)* qtitem.funetprice
ELSE
0
END,
EAUGM =
CASE
WHEN SUBSTRING(qtitem.fdescmemo,1,4) = UPPER('EAU:') THEN
CASE
WHEN SUBSTRING(qtitem.fdescmemo,5,10)* qtitem.funetprice <> 0 THEN
((SUBSTRING(qtitem.fdescmemo,5,10)* qtitem.funetprice) - (qtpest.fmatlcost +
qtpest.ftoolcost + qtpest.flabcost + qtpest.fovhdcost + qtpest.fsubcost +
qtpest.fothrcost + qtpest.fsetupcost)) / (SUBSTRING(qtitem.fdescmemo,5,10)*
qtitem.funetprice)
ELSE
0
END
ELSE
0
END,
'For ' + @dStart + ' thru ' + @dEnd AS Parameters
INTO ztmpQuoteSummary
FROM qtmast INNER JOIN (qtitem INNER JOIN qtpest ON
(qtitem.fpartrev=qtpest.fcpartrev) AND (qtitem.fpartno=qtpest.fpartno) AND
(qtitem.finumber=qtpest.finumber) AND (qtitem.fenumber=qtpest.fenumber) AND
(qtitem.fquoteno=qtpest.fquoteno)) ON qtmast.fquoteno=qtitem.fquoteno
WHERE (((qtmast.fquotedate)>= @dStart And (qtmast.fquotedate)<=@dEnd))
ORDER BY qtmast.fcompany, qtmast.fquoteno, qtmast.frevno;
GO
------------------------------------
how do I call this proc from within VB
--
Thanks
David Davis 5 1599
Hi David,
This should give you the general idea of how to use a command object to
build the parameters and then to execute the stored proc. ocmd2 is the
command object you'll be interested in.
HTH,
Bernie Yaeger
Dim oconn As New SqlConnection("data source=d5z0071;initial
catalog=imc;integrated security=sspi;")
Dim ocmd As New SqlCommand("select * from histd_", oconn)
Try
oconn.Open()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Dim ocmd2 As New SqlCommand
ocmd2 = New SqlCommand("sp_testupdatehistd_", oconn)
Dim oda As New SqlDataAdapter(ocmd2)
Dim pimcacct, pbipad, pissuecode As SqlParameter
ocmd2.CommandType = CommandType.StoredProcedure
pimcacct = ocmd2.Parameters.Add("@mimcacct", SqlDbType.Char, 21)
pbipad = ocmd2.Parameters.Add("@mbipad", SqlDbType.Char, 6)
pissuecode = ocmd2.Parameters.Add("@missuecode", SqlDbType.Char, 15)
pimcacct.Direction = ParameterDirection.Input
pbipad.Direction = ParameterDirection.Input
pissuecode.Direction = ParameterDirection.Input
pimcacct.Value = "12778-000001"
pbipad.Value = "92789"
pissuecode.Value = "200406"
Try
ocmd2.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
oconn.Close()
"David Davis" <Da********@discussions.microsoft.com> wrote in message
news:64**********************************@microsof t.com... I have the following stored procedure in an sql database
------------------------------------ CREATE PROCEDURE zspQuoteSummary @dStart DateTime, @dEnd DateTime AS
SELECT qtmast.fstatus, qtmast.festimator, qtmast.fcompany, qtmast.fquoteno AS Quote, qtmast.frevno AS Rev, qtmast.fquotedate, qtitem.fenumber AS ItemNumber, qtitem.fpartno AS Part, qtitem.fpartrev AS PartRev, qtpest.fmatlcost + qtpest.ftoolcost + qtpest.flabcost + qtpest.fovhdcost + qtpest.fsubcost + qtpest.fothrcost + qtpest.fsetupcost AS TotalCost, qtitem.funetprice AS UnitPrice, qtitem.festqty AS Qty, qtitem.funetprice*qtitem.festqty AS Extended,
GM = CASE WHEN (qtitem.funetprice*qtitem.festqty) <> 0 THEN ((qtitem.funetprice*qtitem.festqty) - (qtpest.fmatlcost + qtpest.ftoolcost + qtpest.flabcost + qtpest.fovhdcost + qtpest.fsubcost + qtpest.fothrcost + qtpest.fsetupcost) )/(qtitem.funetprice*qtitem.festqty) ELSE 0 END,
EAU = CASE WHEN SUBSTRING(qtitem.fdescmemo,1,4) = UPPER('EAU:') THEN SUBSTRING(qtitem.fdescmemo,5,10) ELSE 0 END,
EAUExtended = CASE WHEN SUBSTRING(qtitem.fdescmemo,1,4) = UPPER('EAU:') THEN SUBSTRING(qtitem.fdescmemo,5,10)* qtitem.funetprice ELSE 0 END,
EAUGM = CASE WHEN SUBSTRING(qtitem.fdescmemo,1,4) = UPPER('EAU:') THEN CASE WHEN SUBSTRING(qtitem.fdescmemo,5,10)* qtitem.funetprice <> 0 THEN ((SUBSTRING(qtitem.fdescmemo,5,10)* qtitem.funetprice) - (qtpest.fmatlcost + qtpest.ftoolcost + qtpest.flabcost + qtpest.fovhdcost + qtpest.fsubcost + qtpest.fothrcost + qtpest.fsetupcost)) / (SUBSTRING(qtitem.fdescmemo,5,10)* qtitem.funetprice) ELSE 0 END ELSE 0 END,
'For ' + @dStart + ' thru ' + @dEnd AS Parameters INTO ztmpQuoteSummary FROM qtmast INNER JOIN (qtitem INNER JOIN qtpest ON (qtitem.fpartrev=qtpest.fcpartrev) AND (qtitem.fpartno=qtpest.fpartno) AND (qtitem.finumber=qtpest.finumber) AND (qtitem.fenumber=qtpest.fenumber) AND (qtitem.fquoteno=qtpest.fquoteno)) ON qtmast.fquoteno=qtitem.fquoteno WHERE (((qtmast.fquotedate)>= @dStart And (qtmast.fquotedate)<=@dEnd)) ORDER BY qtmast.fcompany, qtmast.fquoteno, qtmast.frevno; GO ------------------------------------
how do I call this proc from within VB -- Thanks
David Davis
Bernie
Thanks for the code.
I'm able to assign values to the parameters. The only problem I have now is
that I get a syntax error
"Syntax error converting datetime from character string."
How do I pass a datetime value to a datetime parameter. Following is the
code for the parameters.
Dim dStart, dEnd As SqlParameter
dStart = SprocCommand.Parameters.Add("@dStart", SqlDbType.DateTime, 8)
dEnd = SprocCommand.Parameters.Add("@dEnd", SqlDbType.DateTime, 8)
dStart.Direction = ParameterDirection.Input
dEnd.Direction = ParameterDirection.Input
dStart.Value = Me.dteStart.DateTime.ToShortDateString
dEnd.Value = Me.dteEnd.DateTime.ToShortDateString
Thanks
David Davis
"Bernie Yaeger" wrote: Hi David,
This should give you the general idea of how to use a command object to build the parameters and then to execute the stored proc. ocmd2 is the command object you'll be interested in.
HTH,
Bernie Yaeger Dim oconn As New SqlConnection("data source=d5z0071;initial catalog=imc;integrated security=sspi;")
Dim ocmd As New SqlCommand("select * from histd_", oconn)
Try
oconn.Open()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Dim ocmd2 As New SqlCommand
ocmd2 = New SqlCommand("sp_testupdatehistd_", oconn)
Dim oda As New SqlDataAdapter(ocmd2)
Dim pimcacct, pbipad, pissuecode As SqlParameter
ocmd2.CommandType = CommandType.StoredProcedure
pimcacct = ocmd2.Parameters.Add("@mimcacct", SqlDbType.Char, 21)
pbipad = ocmd2.Parameters.Add("@mbipad", SqlDbType.Char, 6)
pissuecode = ocmd2.Parameters.Add("@missuecode", SqlDbType.Char, 15)
pimcacct.Direction = ParameterDirection.Input
pbipad.Direction = ParameterDirection.Input
pissuecode.Direction = ParameterDirection.Input
pimcacct.Value = "12778-000001"
pbipad.Value = "92789"
pissuecode.Value = "200406"
Try
ocmd2.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
oconn.Close()
"David Davis" <Da********@discussions.microsoft.com> wrote in message news:64**********************************@microsof t.com...I have the following stored procedure in an sql database
------------------------------------ CREATE PROCEDURE zspQuoteSummary @dStart DateTime, @dEnd DateTime AS
SELECT qtmast.fstatus, qtmast.festimator, qtmast.fcompany, qtmast.fquoteno AS Quote, qtmast.frevno AS Rev, qtmast.fquotedate, qtitem.fenumber AS ItemNumber, qtitem.fpartno AS Part, qtitem.fpartrev AS PartRev, qtpest.fmatlcost + qtpest.ftoolcost + qtpest.flabcost + qtpest.fovhdcost + qtpest.fsubcost + qtpest.fothrcost + qtpest.fsetupcost AS TotalCost, qtitem.funetprice AS UnitPrice, qtitem.festqty AS Qty, qtitem.funetprice*qtitem.festqty AS Extended,
GM = CASE WHEN (qtitem.funetprice*qtitem.festqty) <> 0 THEN ((qtitem.funetprice*qtitem.festqty) - (qtpest.fmatlcost + qtpest.ftoolcost + qtpest.flabcost + qtpest.fovhdcost + qtpest.fsubcost + qtpest.fothrcost + qtpest.fsetupcost) )/(qtitem.funetprice*qtitem.festqty) ELSE 0 END,
EAU = CASE WHEN SUBSTRING(qtitem.fdescmemo,1,4) = UPPER('EAU:') THEN SUBSTRING(qtitem.fdescmemo,5,10) ELSE 0 END,
EAUExtended = CASE WHEN SUBSTRING(qtitem.fdescmemo,1,4) = UPPER('EAU:') THEN SUBSTRING(qtitem.fdescmemo,5,10)* qtitem.funetprice ELSE 0 END,
EAUGM = CASE WHEN SUBSTRING(qtitem.fdescmemo,1,4) = UPPER('EAU:') THEN CASE WHEN SUBSTRING(qtitem.fdescmemo,5,10)* qtitem.funetprice <> 0 THEN ((SUBSTRING(qtitem.fdescmemo,5,10)* qtitem.funetprice) - (qtpest.fmatlcost + qtpest.ftoolcost + qtpest.flabcost + qtpest.fovhdcost + qtpest.fsubcost + qtpest.fothrcost + qtpest.fsetupcost)) / (SUBSTRING(qtitem.fdescmemo,5,10)* qtitem.funetprice) ELSE 0 END ELSE 0 END,
'For ' + @dStart + ' thru ' + @dEnd AS Parameters INTO ztmpQuoteSummary FROM qtmast INNER JOIN (qtitem INNER JOIN qtpest ON (qtitem.fpartrev=qtpest.fcpartrev) AND (qtitem.fpartno=qtpest.fpartno) AND (qtitem.finumber=qtpest.finumber) AND (qtitem.fenumber=qtpest.fenumber) AND (qtitem.fquoteno=qtpest.fquoteno)) ON qtmast.fquoteno=qtitem.fquoteno WHERE (((qtmast.fquotedate)>= @dStart And (qtmast.fquotedate)<=@dEnd)) ORDER BY qtmast.fcompany, qtmast.fquoteno, qtmast.frevno; GO ------------------------------------
how do I call this proc from within VB -- Thanks
David Davis
David Davis wrote: Bernie
Thanks for the code.
I'm able to assign values to the parameters. The only problem I have now is that I get a syntax error
"Syntax error converting datetime from character string."
How do I pass a datetime value to a datetime parameter. Following is the code for the parameters.
Dim dStart, dEnd As SqlParameter dStart = SprocCommand.Parameters.Add("@dStart", SqlDbType.DateTime, 8) dEnd = SprocCommand.Parameters.Add("@dEnd", SqlDbType.DateTime, 8) dStart.Direction = ParameterDirection.Input dEnd.Direction = ParameterDirection.Input dStart.Value = Me.dteStart.DateTime.ToShortDateString dEnd.Value = Me.dteEnd.DateTime.ToShortDateString
Thanks
David Davis
"Bernie Yaeger" wrote:
about this: dStart.Value = Me.dteStart.DateTime.ToShortDateString
Why do you convert it to shortdatestring?
--
Rinze van Huizen
C-Services Holland b.v.
I'm using the shortdatestring because even though the field in sql is
datetime they are only storing the first 8 positions (the date).
I found out that the problem was not with the assigning of the parameter to
pass but a header line:
'For ' + @dStart + ' thru ' + @dEnd AS hdrLine
I had to change the header line to look like this:
'For ' + Convert(VarChar, @dStart, 101) + ' thru ' + Convert(VarChar,@dEnd,
101) AS hdrLine
"C-Services Holland b.v." wrote: David Davis wrote: Bernie
Thanks for the code.
I'm able to assign values to the parameters. The only problem I have now is that I get a syntax error
"Syntax error converting datetime from character string."
How do I pass a datetime value to a datetime parameter. Following is the code for the parameters.
Dim dStart, dEnd As SqlParameter dStart = SprocCommand.Parameters.Add("@dStart", SqlDbType.DateTime, 8) dEnd = SprocCommand.Parameters.Add("@dEnd", SqlDbType.DateTime, 8) dStart.Direction = ParameterDirection.Input dEnd.Direction = ParameterDirection.Input dStart.Value = Me.dteStart.DateTime.ToShortDateString dEnd.Value = Me.dteEnd.DateTime.ToShortDateString
Thanks
David Davis
"Bernie Yaeger" wrote:
about this: dStart.Value = Me.dteStart.DateTime.ToShortDateString Why do you convert it to shortdatestring?
-- Rinze van Huizen C-Services Holland b.v.
Hi David,
I think it's the value of the date variables that is the problem.
The following works fine for me:
Dim ocmd3 As New SqlCommand
ocmd3 = New SqlCommand("testdatevar", oconn)
Dim oda3 As New SqlDataAdapter(ocmd3)
Dim pdate As SqlParameter
ocmd3.CommandType = CommandType.StoredProcedure
pdate = ocmd3.Parameters.Add("@datevar", SqlDbType.DateTime, 8)
pdate.Direction = ParameterDirection.Input
pdate.Value = #1/1/2004#
Try
ocmd3.ExecuteNonQuery()
MessageBox.Show("fine")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
HTH,
Bernie Yaeger
"David Davis" <Da********@discussions.microsoft.com> wrote in message
news:BE**********************************@microsof t.com... I'm using the shortdatestring because even though the field in sql is datetime they are only storing the first 8 positions (the date).
I found out that the problem was not with the assigning of the parameter to pass but a header line:
'For ' + @dStart + ' thru ' + @dEnd AS hdrLine
I had to change the header line to look like this:
'For ' + Convert(VarChar, @dStart, 101) + ' thru ' + Convert(VarChar,@dEnd, 101) AS hdrLine
"C-Services Holland b.v." wrote:
David Davis wrote: > Bernie > > Thanks for the code. > > I'm able to assign values to the parameters. The only problem I have > now is > that I get a syntax error > > "Syntax error converting datetime from character string." > > How do I pass a datetime value to a datetime parameter. Following is > the > code for the parameters. > > Dim dStart, dEnd As SqlParameter > dStart = SprocCommand.Parameters.Add("@dStart", > SqlDbType.DateTime, 8) > dEnd = SprocCommand.Parameters.Add("@dEnd", SqlDbType.DateTime, > 8) > dStart.Direction = ParameterDirection.Input > dEnd.Direction = ParameterDirection.Input > dStart.Value = Me.dteStart.DateTime.ToShortDateString > dEnd.Value = Me.dteEnd.DateTime.ToShortDateString > > Thanks > > David Davis > > "Bernie Yaeger" wrote: >
about this: dStart.Value = Me.dteStart.DateTime.ToShortDateString Why do you convert it to shortdatestring?
-- Rinze van Huizen C-Services Holland b.v. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: dw |
last post by:
Hello all, I'm having a dickens of a time calling a stored procedure on a
connection. Every time I do, it generates an error "Arguments are of the
wrong type, are out of acceptable range, or are in...
|
by: Bob Murdoch |
last post by:
I have an ASP application that calls a COM function to create a custom
report as an Excel file. This works in a synchronous fashion, as long as
the report does not take too long to create. If...
|
by: Anthony Robinson |
last post by:
I'm executing a stored procedure and getting the
SQL0440N No authorized routine named
"AMROBI2.CREATEAIMCONNECTION" of type "PROCEDURE
" having compatible arguments was found.
The schema...
|
by: Woody Splawn |
last post by:
I am using SQL Server 2000 as the back-end. I have created a stored
procedure in SQL server called usp_AddContract. This Stored procedure
inserts a new contract into a contracts table. I have...
|
by: singlal |
last post by:
Hi, my question was not getting any attention because it moved to 2nd
page; so posting it again. Sorry for any inconvenience but I need to
get it resolved fast. Need your help!
...
|
by: Jack |
last post by:
Hi,
I am trying to run an example code from a book. However I am getting the
following error message:
Number: -2147217900
Description: Syntax error or access violation
Source: Microsoft OLE...
|
by: eighthman11 |
last post by:
I'm calling a stored procedure on a sql server from an access
application. I just need the stored procedure to run I do not need any
data returned from the stored procedure to my Access...
|
by: amgupta8 |
last post by:
Note: This problem occurred when I updated the JDK from 1.3.1 to 1.4.1 or 1.4.2.
Nothing else was changed in the code, other than updating the JDK on the database server (dbm cfg parm jdk_path) and...
|
by: aravindalapat |
last post by:
Hi All,
I am facing an error when I try to invoke a remote nested stored proc. Please find the details below.
1) SP TEST1 is defined in DB2 instance DB2A. It is calling a stored procedure
...
|
by: Soniad |
last post by:
Hello,
I am excecuting a stored procedure in my ASP page , it has one out parameter (@confirm) . after executing the procedure i want to retreive this out parameter and assign it to variable...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |