Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET 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 September 7th, 2004, 09:36 AM
Registered User
 
Join Date: Sep 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default objCommand.Parameters.Add......Field Declar Prob

I am studying the WROX vb.net 2003 book to learn how to save data to an sql database. On page 532-533 it discusses using the objCommand.Paramters.Add command to save data to the SQL database. I thought I had already delared my variables but it is hanging up on the @variables. Do I have to delcare each of these as variables also?????

Here is the error message

Line 1:Incorrect Syntax near '('.
Must delcare the variable

Here is my code. '@readingElaobj'.

Must delare the variable '@admDate'.

Try

                'Write ELA Objective Info record
                Dim objConnection As SqlConnection = New SqlConnection("server=(local);database=FBISD-TAKS;user id=sa;password=pa55word")
                Dim objCommand As SqlCommand = New SqlCommand
                objCommand.Connection = objConnection

                Dim r4 As Int32
                For r4 = 1 To 51
                    objCommand.CommandText = "Insert Into itemAnalysisDetail " & "(admDate, studentId, teacherId, objectiveNumber, itemCorrectResp, studentResp) " & _
                                "VALUES(@admDate,@studentId,@teacherId,@readingEla obj(r4),@readingElaItemCorrectRespArray(r4),@readi ngElaStudentRespArray(r4))"
                    objCommand.Parameters.Add("@admDate", admDate)
                    objCommand.Parameters.Add("@studentId", studentId)
                    objCommand.Parameters.Add("@teacherId", teacherId)
                    objCommand.Parameters.Add("@readingElaobj(r4)", readingElaobj(r4))
                    objCommand.Parameters.Add("@readingElaItemCorrectR espArray(r4)", readingElaItemCorrectRespArray(r4))
                    objCommand.Parameters.Add("@readingElaStudentRespA rray(r4)", readingElaStudentRespArray(r4))


                    objConnection.Open()
                    objCommand.ExecuteNonQuery()
                    objConnection.Close()
                Next
            Catch ex As Exception
                MsgBox(ex.Message)

            End Try






Similar Threads
Thread Thread Starter Forum Replies Last Post
dynamically Parameters.Add for storedProc havey C# 2 November 27th, 2007 02:41 PM
add a new row when cursor comes to the last field bullsb Classic ASP Professional 8 March 11th, 2007 04:11 PM
How Do I add Parameters to hyperlinks in reports mikehsu317 BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 1 February 4th, 2005 05:02 AM
Enabling Required Field Validator prob. lucho1970 ASP.NET 1.0 and 1.1 Professional 3 October 23rd, 2004 10:17 AM
Add field to top of recordset vertigo Beginning VB 6 6 July 14th, 2004 03:24 AM





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