Wrox Programmer Forums
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 25th, 2006, 11:56 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default Stored Procedure Call Syntax

Does anyone know if you can use text command type syntax like the following to call a proc in VN.NET:

"{CALL procGetCustomer(?)}"

It works fine in C#, but can't seem to get it going in VB.NET. Here's my proc call:

Code:
Call m_CallStoredProcedureTextCommadType(SQLSERVER_CONNECTION_STRING, "{CALL procGetCustomer(?)}")
And here's the procedure:

Code:
Public Sub m_CallStoredProcedureTextCommadType(ByVal strConnectionString As String, ByVal strText As String)
        Dim cnn As New OleDbConnection(strConnectionString)
        cnn.Open()

        Dim cmd As OleDbCommand = cnn.CreateCommand()
        With cmd
            .CommandText = strText
            .CommandType = CommandType.Text
            .Parameters.Add("@CustomerID", OleDbType.WChar, 5)
            .Parameters(0).Value = "ALFKI"
        End With

        Dim dr As OleDbDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
        If dr.Read() Then
            Console.WriteLine(dr("CompanyName"))
        Else
            Console.WriteLine("No customer found.")
        End If

        dr.Close()
    End Sub
The stored procedure exists and works fin when called by Query Analyzer or my C# version of the procedure.

Thanks,

Bob



 
Old March 26th, 2006, 01:43 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Oops...never mind. The above works fine in VB.NET too. Just had my VB.NET connection pointed at the wrong database.

Bob






Similar Threads
Thread Thread Starter Forum Replies Last Post
Stored Procedure call from CFMX Colonel Angus SQL Server 2000 0 September 20th, 2006 08:27 AM
How to call a Oracle Stored Procedure in VB6 krratnesh Pro VB Databases 1 February 19th, 2006 11:56 AM
Call a Stored Procedure Macsood ASP.NET 1.0 and 1.1 Basics 1 October 31st, 2005 11:29 AM
Cobol Stored procedure call ParasJain01 Java Databases 0 February 1st, 2005 02:53 PM
Stored Procedure Syntax Problem MaxGay SQL Server 2000 1 November 4th, 2004 05:16 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.