Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
| Search | Today's Posts | Mark Forums Read
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
  #1 (permalink)  
Old November 7th, 2006, 12:11 PM
Authorized User
 
Join Date: Nov 2006
Location: Lorain, OH, USA.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to pass a parameter to a stored procedure?

What syntax do I use to pass a parameter to a stored procedure from vb.net

Thank you in advance,

Max

  #2 (permalink)  
Old November 8th, 2006, 02:48 PM
Friend of Wrox
 
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You must use the parameters collection of the command object.
Depending on which data provider you are using (Sql, Ole, Oracle, etc) the names are a bit different, but basically:

Dim cmd As New OleDb.OleDbCommand
cmd.Connection = conn ' Assumes you have an open connection named conn
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "STORED_PROC_NAME_HERE"
cmd.Parameters.Add("ParamName", strValue)
cmd.ExecuteNonQuery() ' You can also ExecuteReader or ExecuteScalar

These are the basics and should get you started.

Woody Z http://www.learntoprogramnow.com


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pass XML parameter to stored procedure BCullenward Classic ASP Databases 3 September 10th, 2008 02:07 PM
pass null to the parameter in the stored procedure kokila BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 July 12th, 2007 03:02 AM
how to pass value to stored procedure? hertendreef SQL Server 2005 3 February 23rd, 2007 11:43 AM
Pass an Array as a Parameter to a Stored Procedure booksnore2 Oracle 0 August 31st, 2004 09:20 AM
How will I pass stored procedure in an asp shoakat SQL Server 2000 1 July 15th, 2004 10:28 PM





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