Solved

ret row return

Posted on 2011-09-02
2
380 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

726 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