473,408 Members | 1,875 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

VB.Net Stored Procedures

I'm trying to call a stored procedure from vb.net that's on the sql server. I
would like to have the output on another form or a listbox where I can print
results. I'm not getting any errors, but i'm not getting any output either.
Any help appreciated. Thanks.

'Stored Procedure = COMPARE, Output = comp_out. COL001 is returned 'field
from SP.

Dim myCommand As New SqlCommand
Dim myParameter As SqlParameter

Dim myConnection = New SqlConnection("Integrated Security=SSPI;Packet
Size=4096;Data Source=TEST\MYSQL;Initial Catalog=hutty;Persist Security
Info=False;Workstation ID=TEST")

myCommand.Connection = myConnection
myCommand.CommandText = "COMPARE"
myCommand.CommandType = CommandType.StoredProcedure
myParameter = myCommand.CreateParameter()
myParameter.ParameterName = "@comp_out"
myParameter.Direction = ParameterDirection.Output
myParameter.SqlDbType = SqlDbType.VarChar
myParameter.Size = 50
myCommand.Parameters.Add(myParameter)

myCommand.Connection.Open()
myCommand.ExecuteNonQuery()

Span1.Text =
Convert.ToString((myCommand.Parameters("@comp_out" ).Value.ToString()))

ListBox1.Items.Add(myCommand.Parameters("@comp_out ").Value.ToString)

--
Hutty
Jan 24 '06 #1
2 1273
Have you check first that your store procedure itseld is working fine from
server side?
"Hutty" wrote:
I'm trying to call a stored procedure from vb.net that's on the sql server. I
would like to have the output on another form or a listbox where I can print
results. I'm not getting any errors, but i'm not getting any output either.
Any help appreciated. Thanks.

'Stored Procedure = COMPARE, Output = comp_out. COL001 is returned 'field
from SP.

Dim myCommand As New SqlCommand
Dim myParameter As SqlParameter

Dim myConnection = New SqlConnection("Integrated Security=SSPI;Packet
Size=4096;Data Source=TEST\MYSQL;Initial Catalog=hutty;Persist Security
Info=False;Workstation ID=TEST")

myCommand.Connection = myConnection
myCommand.CommandText = "COMPARE"
myCommand.CommandType = CommandType.StoredProcedure
myParameter = myCommand.CreateParameter()
myParameter.ParameterName = "@comp_out"
myParameter.Direction = ParameterDirection.Output
myParameter.SqlDbType = SqlDbType.VarChar
myParameter.Size = 50
myCommand.Parameters.Add(myParameter)

myCommand.Connection.Open()
myCommand.ExecuteNonQuery()

Span1.Text =
Convert.ToString((myCommand.Parameters("@comp_out" ).Value.ToString()))

ListBox1.Items.Add(myCommand.Parameters("@comp_out ").Value.ToString)

--
Hutty

Jan 24 '06 #2
Yes... I checked the SP through query analyzer. I did make a modification
after this post. The parameter name "comp_out" I deleted from the SP. It
wasn't needed. This is my SP that I'm trying to get the output in VB:

CREATE PROCEDURE [DBO].[COMPARE]
AS
SELECT MIN(TableName) as TableName, COL001
FROM

(
SELECT '[FILE1]' as TableName, Col001
FROM [FILE1]
UNION ALL
SELECT '[FILE2]' as TableName, Col001
FROM [FILE2]
) tmp
GROUP BY COL001
HAVING COUNT(*) = 1
ORDER BY COL001
GO
--
Hutty
"serge calderara" wrote:
Have you check first that your store procedure itseld is working fine from
server side?
"Hutty" wrote:
I'm trying to call a stored procedure from vb.net that's on the sql server. I
would like to have the output on another form or a listbox where I can print
results. I'm not getting any errors, but i'm not getting any output either.
Any help appreciated. Thanks.

'Stored Procedure = COMPARE, Output = comp_out. COL001 is returned 'field
from SP.

Dim myCommand As New SqlCommand
Dim myParameter As SqlParameter

Dim myConnection = New SqlConnection("Integrated Security=SSPI;Packet
Size=4096;Data Source=TEST\MYSQL;Initial Catalog=hutty;Persist Security
Info=False;Workstation ID=TEST")

myCommand.Connection = myConnection
myCommand.CommandText = "COMPARE"
myCommand.CommandType = CommandType.StoredProcedure
myParameter = myCommand.CreateParameter()
myParameter.ParameterName = "@comp_out"
myParameter.Direction = ParameterDirection.Output
myParameter.SqlDbType = SqlDbType.VarChar
myParameter.Size = 50
myCommand.Parameters.Add(myParameter)

myCommand.Connection.Open()
myCommand.ExecuteNonQuery()

Span1.Text =
Convert.ToString((myCommand.Parameters("@comp_out" ).Value.ToString()))

ListBox1.Items.Add(myCommand.Parameters("@comp_out ").Value.ToString)

--
Hutty

Jan 24 '06 #3

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

Similar topics

11
by: jrefactors | last post by:
I want to know the differences between SQL Server 2000 stored procedures and oracle stored procedures? Do they have different syntax? The concept should be the same that the stored procedures...
2
by: scott | last post by:
Hi, Just wondering what sort of problems and advantages people have found using stored procedures. I have an app developed in VB6 & VB.NET and our developers are starting to re-write some of the...
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...
2
by: Eli | last post by:
Hi all We currently have a strange problem with calling a Stored Procedure (SQL Database) in our C# Project. The only error I get is "System error" which says a lot :) Background: We have...
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...
45
by: John | last post by:
Hi When developing vb.bet winform apps bound to sql server datasource, is it preferable to use SELECTs or stored procedure to read and write data from/to SQL Server? Why? Thanks Regards
28
by: mooreit | last post by:
The purpose for my questions is accessing these technologies from applications. I develop both applications and databases. Working with Microsoft C#.NET and Microsoft SQL Server 2000 Production and...
11
by: peter | last post by:
I am trying to get a SQL stored procedure to use user maintained MQT implicitly which raises questions on when they are used or not used. In theory you would expect the stored procedure to pick up...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
jinu1996
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...
0
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
tracyyun
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...
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,...

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.