[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

ret row return

Posted on 2011-09-02
2
Medium Priority
?
388 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 248 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 252 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

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 I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

656 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