jamie_pattison
Well-known member
- Joined
- Sep 9, 2008
- Messages
- 116
- Programming Experience
- Beginner
Im trying to retrieve some data from a database using a stored procedure. Heres my code:
Dim connectionString As String = "server=test; database=testdb; integrated security=true;"
Dim sqlCon As New SqlConnection(connectionString)
Dim sqlComm As SqlCommand = New SqlCommand
Dim sdr As SqlDataReader
sqlComm.Connection = sqlCon
sqlComm.CommandText = "A_Stored_Procedure"
sqlComm.CommandType = CommandType.StoredProcedure
sqlCon.Open()
sdr = sqlComm.ExecuteReader
DataGridView1.DataSource = sdr.Read
DataGridView1.Show()
sqlCon.Close()
Unfortunately this doesnt return any results so i dont knwo if the Stored Procedure is at fault or this code? When i run the Procedure in SQL studio i does return the output i require. Heres the code for my stored procedure
USE [Testdb]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[Test]
AS
SELECT * FROM
Table
Can anyone advise please?
Thanks
Dim connectionString As String = "server=test; database=testdb; integrated security=true;"
Dim sqlCon As New SqlConnection(connectionString)
Dim sqlComm As SqlCommand = New SqlCommand
Dim sdr As SqlDataReader
sqlComm.Connection = sqlCon
sqlComm.CommandText = "A_Stored_Procedure"
sqlComm.CommandType = CommandType.StoredProcedure
sqlCon.Open()
sdr = sqlComm.ExecuteReader
DataGridView1.DataSource = sdr.Read
DataGridView1.Show()
sqlCon.Close()
Unfortunately this doesnt return any results so i dont knwo if the Stored Procedure is at fault or this code? When i run the Procedure in SQL studio i does return the output i require. Heres the code for my stored procedure
USE [Testdb]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[Test]
AS
SELECT * FROM
Table
Can anyone advise please?
Thanks
Last edited: