473,466 Members | 1,324 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Accessing SQL Stored Procedures from VB code

I am having an issue w/regard to stored procedures. If I do the
following:

Dim OccCnctn As New OleDb.OleDbConnection
Dim OccCmd As New OleDb.OleDbCommand
Dim OccRdr As OleDb.OleDbDataReader
OccCnctn.ConnectionString = "Integrated Security=SSPI;Packet
Size=4096;Data Source='COMTEK-9100WXP';Tag with column collation when
possible=False;Initial Catalog=Move Manager;Use Procedure for
Prepare=1;Auto Translate=True;Persist Security
Info=False;Provider='SQLOLEDB.1';Workstation ID='COMTEK-9100WXP';Use
Encryption for Data=False"

OccCnctn.Open()
OccCmd.Connection = OccCnctn
OccCmd.CommandText() = "SELECT max_occup, No_of_Occup FROM
MM_Spaces_Existing where site = '" & DDLTSite.SelectedItem.Text & "' and
Building = '" & DDLTBldg.SelectedItem.Text & "' and Flr = '" &
DDLTFlr.SelectedItem.Text & "' and room = '" & DDLTRm.SelectedItem.Text
& "'"

OccRdr = OccCmd.ExecuteReader()
OccRdr.Read()

If OccRdr.HasRows Then

When I get to the HasRows it is True which is correct. If I try to use
a stored procedure and vb code as follows:

CREATE PROCEDURE dbo.MM_Get_Max_No_Occs @Site nvarchar, @Bldg nvarchar ,
@Floor nvarchar, @Room nvarchar

AS
Declare @ErrSave int
Set @ErrSave = 0

SELECT max_occup, No_of_Occup FROM MM_Spaces_Existing
where Site = @Site and Building = @Bldg and Flr = @Floor and Room =
@Room;

If (@@ERROR <> 0)
Set @ErrSave = @@ERROR

return @ErrSave
GO
with the following VB code

Dim OccCnctn As New OleDb.OleDbConnection
Dim OccCmd As New OleDb.OleDbCommand
Dim OccRdr As OleDb.OleDbDataReader
OccCnctn.ConnectionString = "Integrated Security=SSPI;Packet
Size=4096;Data Source='COMTEK-9100WXP';Tag with column collation when
possible=False;Initial Catalog=Move Manager;Use Procedure for
Prepare=1;Auto Translate=True;Persist Security
Info=False;Provider='SQLOLEDB.1';Workstation ID='COMTEK-9100WXP';Use
Encryption for Data=False"

OccCnctn.Open()
OccCmd.Connection = OccCnctn

OccCmd.CommandType = CommandType.StoredProcedure
OccCmd.Parameters.Add("@Site", OleDb.OleDbType.VarChar).Value =
DDLTSite.SelectedItem.Text
OccCmd.Parameters.Add("@Bldg", OleDb.OleDbType.VarChar).Value =
DDLTBldg.SelectedItem.Text
OccCmd.Parameters.Add("@Floor", OleDb.OleDbType.VarChar).Value =
DDLTFlr.SelectedItem.Text
OccCmd.Parameters.Add("@Room", OleDb.OleDbType.VarChar).Value =
DDLTRm.SelectedItem.Text
OccCmd.CommandText = "MM_Get_Max_No_Occs"

OccRdr = OccCmd.ExecuteReader()
OccRdr.Read()

If OccRdr.HasRows Then

then hasrows is false. Any suggestions?

Evan Kontos | EK*****@comtekcadd.com

27 Whitehall St. | 3rd Floor | New York, NY 10004
Tel 212.480.8166 | Fax 212.480.8167 | Personal Fax 786.513.0295
www.comtekcadd.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #1
1 1439
* Evan Kontos <ek*****@comtekcadd.com> scripsit:
I am having an issue w/regard to stored procedures. If I do the
following:

Dim OccCnctn As New OleDb.OleDbConnection


Notice that a separate group for ADO.NET related question is available:

<news://msnews.microsoft.com/microsoft.public.dotnet.framework.adonet>

Web interface:

<http://msdn.microsoft.com/newsgroups/default.asp?url=/newsgroups/loadframes.asp?icp=msdn&slcid=us&newsgroup=microso ft.public.dotnet.framework.adonet>

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: serge | last post by:
How can i delete all user stored procedures and all table triggers very fast in a single database? Thank you
4
by: stjulian | last post by:
I have a stored procedure that is supposed to 1. Increment a counter in Table A via a transaction 2. Use this value as the primary key to add in an address to customers Table B (Referenced as a...
3
by: Rhino | last post by:
I've spent the last couple of hours trying to figure out how to debug a Java stored procedure and am just going in circles. The last straw came when I got "Cannot open input stream for default"...
2
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered...
5
by: Rhino | last post by:
I am trying to determine the behaviour of stored procedures in DB2 V8.2.x in Windows/Unix/Linux and how I can control that behaviour. Some documentation in the manuals is confusing the issue...
5
by: Tim Marshall | last post by:
I was following the thread "Re: Access Treeview - Is it Safe Yet?" with interest and on reading the post describing Lauren Quantrell's SmartTree, I've run into something I don't understand: Stored...
0
by: Amber | last post by:
Stored procedures are faster and more efficient than in-line SQL statements. In this article we will look at two SQL Server stored procedures; one using an input parameter and one not, and see how...
12
by: Steve Blinkhorn | last post by:
Does anyone know of a way of accessing and modifying variables declared static within a function from outside that function? Please no homilies on why it's bad practice: the context is very...
0
by: KAData | last post by:
I have a program that will access remote stored procedures via visual basic.net application. I have SQL Server Management Studio Express (2005) installed on the client computers that will be...
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
1
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...
0
agi2029
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,...
0
isladogs
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.