ado.net to sql server store procedure 
Author Message
 ado.net to sql server store procedure

hi,
In vb6 I used sql server 2000 store procedures to get recordsets and
update data.  I now have vb.net and want to use ado.net to get
recordsets and update data using store procedures for sql 2000.  how
do i do so with ado.net?  i already have the store procedures , just
not the vb code.

thanks
Antonio



Sat, 08 Jan 2005 03:53:03 GMT  
 ado.net to sql server store procedure
You can try something like this:

Dim cmd As New SqlClient.SqlCommand("SP_SaveSketchImage", connect)
initializes the stored procedure that you want.
        Dim p As SqlClient.SqlParameter
initializes so you can pass over parameters

-=-=-

Imports System.Data
Imports System.Data.SqlClient
Imports System.IO

Public Sub SaveImageToDatabase(ByVal FileName As String)
        ' Database operation variables
        Dim Blank As String = ""
        Dim connect As New
SqlClient.SqlConnection("server=KNIGHT;database=RealEstate;trusted_connectio
n=yes")

        Dim cmd As New SqlClient.SqlCommand("SP_SaveSketchImage", connect)
        Dim p As SqlClient.SqlParameter

        ' File/data variables
        Dim imageStream As New FileStream(FileName, IO.FileMode.Open)
        Dim imageData(imageStream.Length) As Byte

        ' Read the image data and close the stream
        imageStream.Read(imageData, 0, imageStream.Length)
        imageStream.Close()

        ' Save the image
        cmd.CommandType = CommandType.StoredProcedure
        Blank = IO.Path.GetFileNameWithoutExtension(FileName)


        p.Value = DP(Blank, "-", 1)
        cmd.Parameters.Add(p)

        p.Value = DP(Blank, "-", 2)
        cmd.Parameters.Add(p)

        p.Value = DP(Blank, "-", 3)
        cmd.Parameters.Add(p)

        p.Value = imageData
        cmd.Parameters.Add(p)

        connect.Open()
        cmd.ExecuteNonQuery()
        connect.Close()

        cmd.Dispose()
        connect.Dispose()
    End Sub
-=-=-=-=

regards,

Chris



Sat, 08 Jan 2005 05:03:07 GMT  
 ado.net to sql server store procedure
The help topic "Executing a Data Command That Returns a Result Set" covers
this pretty well.
Here's the URL...
ms-help://MS.VSCC/MS.MSDNVS/vbcon/html/vbtskExecutingDataCommandThatReturnsR
esultSet.htm

Hope this helps
Ron and Steve
Visual Basic Team

--
This posting is provided "AS IS" with no warranties, and confers no rights.

Quote:
> hi,
> In vb6 I used sql server 2000 store procedures to get recordsets and
> update data.  I now have vb.net and want to use ado.net to get
> recordsets and update data using store procedures for sql 2000.  how
> do i do so with ado.net?  i already have the store procedures , just
> not the vb code.

> thanks
> Antonio



Tue, 11 Jan 2005 04:55:40 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. ASP.net VB.Net Stored Procedures in SQL Server

2. VB.NET,SQL SERVER 2000 STORED PROCEDURE PARAMETERS, CRYSTAL REPORTS

3. Using ADO to access a Stored Procedure in SQL Server

4. ADO Output Parameter with Stored Procedure in SQL Server 7

5. VB 5 - ADO adOpenKeySet cursor problem with SQL Server stored procedures using Variables

6. VB 5 - ADO adOpenKeySet cursor problem with SQL Server stored procedures using Variables

7. Passing parameter from VB 6 ADO Data Control to SQL Server Stored Procedure

8. NULLs and SQL Server Stored Procedures with ADO

9. ADO with Stored Procedure and Temporary SQL Server Tables

10. ADO Output Parameter with Stored Procedure in SQL Server 7

11. Opening an ADO recordset against a dataset returned from a SQL Server Stored Procedure

12. SQL Server Stored Procedure/VB 6 ADO

 

 
Powered by phpBB® Forum Software