Solved

ret row return

Posted on 2011-09-02
2
368 Views
Last Modified: 2012-05-12
How can I get a return row when I run a store procedure?
Say i have a store procedure name called "Order_select_all". Can I run a seperate select statement to get row count?

like

exec Order_select_all
select rows return etct...

sorry, I am new here.
0
Comment
Question by:VBdotnet2005
2 Comments
 
LVL 6

Assisted Solution

by:c1nmo
c1nmo earned 62 total points
ID: 36476528

For UPDATE,INSERT,DELETE:
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.executenonquery(v=vs.71).aspx

For SELECT something like:

Imports System.Data.SqlClient
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim connetionString As String
        Dim connection As SqlConnection
        Dim command As SqlCommand
        Dim adapter As New SqlDataAdapter
        Dim ds As New DataSet
        Dim sql As String

            connetionString = "Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password"
            sql = "Your SQL Statement Here"
        connection = New SqlConnection(connetionString)

        Try
            connection.Open()
            command = New SqlCommand(sql, connection)
            adapter.SelectCommand = command
            adapter.Fill(ds, "SQL Temp Table")
            adapter.Dispose()
            command.Dispose()
            connection.Close()

            MsgBox("Number of row(s)  -  " & ds.Tables(0).Rows.Count)

        Catch ex As Exception
            MsgBox("Can not open connection ! ")
        End Try
    End Sub
End Class
 

0
 
LVL 9

Accepted Solution

by:
mimran18 earned 63 total points
ID: 36479493
try this.

Drop TABLE [dbo].[Test]
Go
CREATE TABLE [dbo].[Test](
    [ID] int,
      [Name] [nvarchar](50)
)
GO

Insert into [test] values (1,'test1')
Insert into [test] values (2,'test2')
Insert into [test] values (3,'test3')
GO
Drop Procedure test_sp
Go

Create Procedure test_sp
as
Select * from test
Select @@rowcount
Go
test_sp
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now