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 July 11th, 2005, 08:35 AM
Authorized User
 
Join Date: Oct 2004
Location: Bristol, Nth. Somerset, United Kingdom.
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default Passing parameters to a sql stored procedure

I'm trying to call a stored procedure in the Northwind database with a single input parameter but I'm having trouble with the correct syntax. The code I've got is below. I've commented out a couple attempts which caused errors. The errors I think were reported as syntax errors at run time. So I think the code was passed to SQL which looked at it, had a laugh and returned an error. Any ideas?

 Dim conn As New SqlConnection
        conn.ConnectionString = "Trusted_Connection=yes;Addr=P2000;Initial Catalog=Northwind"
        conn.Open()

        Dim comm As New SqlCommand
        comm.Connection = conn
        comm.CommandType = CommandType.StoredProcedure
        comm.CommandText = "CustOrdersDetail @Cust"
        'comm.Parameters.Add("@Cust", SqlDbType.Int, 10248)
        'comm.Parameters("Cust").Value = 10248

        Dim dreader As SqlDataReader
        dreader = comm.ExecuteReader()

        While dreader.Read()
            TextBox1.Text = TextBox1.Text + dreader("ProductName").ToString + vbCrLf
        End While


Similar Threads
Thread Thread Starter Forum Replies Last Post
One textbox, Two Parameters, with Stored Procedure GailCG Classic ASP Professional 0 March 3rd, 2006 03:39 PM
passing parameters to stored procedure in crystal prankur ASP.NET 1.0 and 1.1 Basics 0 January 10th, 2006 03:29 AM
Passing Variable MS Proj to SQL Stored Procedure Abaxt Access VBA 2 July 7th, 2005 11:05 AM
stored procedure with parameters Danmalam VB Databases Basics 0 February 27th, 2005 03:52 PM
Passing Parameters >32k to Oracle stored procedure gp_mk ADO.NET 2 December 22nd, 2003 12:49 PM





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