Re: Error message and can not figure it out
From: Triptaz (Triptaz_at_discussions.microsoft.com)
Date: 03/20/05
- Previous message: Neal B. Scott: "Re: Error message and can not figure it out"
- In reply to: Neal B. Scott: "Re: Error message and can not figure it out"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 19 Mar 2005 19:37:10 -0800
okay thanks i will try that
"Neal B. Scott" wrote:
> See http://www.4guysfromrolla.com/webtech/092601-1.shtml
>
> Use question marks. Basically you want:
> insertcmd = "INSERT INTO ESCustomermain values (?,?,?,?,?,?,?,?,?,?,?);"
> myCommand = New SqlCommand(insertcmd)
> mycommand.parameters.add("Boothnumber",txtBooth.Text)
> mycommand.parameters.add("Firstname",txtFirst.Text)
> mycommand.parameters.add("Lastname",txtLast.Text)
> mycommand.parameters.add("Company",txtCompanyname.Text)
> mycommand.parameters.add("Address",txtAddress.Text)
> mycommand.parameters.add("City",txtCity.Text)
> mycommand.parameters.add("State", txtState.Text)
> mycommand.parameters.add("zip",txtZip.Text)
> mycommand.parameters.add("Phone",txtphone.Text)
> mycommand.parameters.add("Fax",txtfax.Text)
> mycommand.parameters.add("Email",txtEmail.Text)
>
> "Triptaz" <Triptaz@discussions.microsoft.com> wrote in message
> news:04B91DAF-FEC9-407A-BB31-0A721EB8F292@microsoft.com...
> > Here is my code that i have written:
> > Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles btnAdd.Click
> > Dim myCommand As SqlCommand
> > Dim insertcmd As String
> >
> > insertcmd = "INSERT INTO ESCustomermain
> > values(@Boothnumber,@Firstname,@Lastname,@Company,@Address,@City,@State,@zip,@Phone,@Fax,@Email);"
> > myCommand = New SqlCommand(insertcmd)
> > myCommand.Parameters("@Boothnumber").Value = txtBooth.Text
> > myCommand.Parameters("@Firstname").Value = txtFirst.Text
> > myCommand.Parameters("@Lastname").Value = txtLast.Text
> > myCommand.Parameters("@Compnay").Value = txtCompanyname.Text
> > myCommand.Parameters("@Address").Value = txtAddress.Text
> > myCommand.Parameters("@City").Value = txtCity.Text
> > myCommand.Parameters("@State").Value = txtState.Text
> > myCommand.Parameters("@Zip").Value = txtZip.Text
> > myCommand.Parameters("@Email").Value = txtEmail.Text
> > what i am trying to do is when i enter new information into the forms text
> > boxes i want to add this as a new record. i do not know if i am doing this
> > wrong. i have a connection to the database using a sqldataadapter and a
> > dataset. which shows me the data in the databse that i manually put in
> > there
> > through SQL ENt Manager. so i know i have a connection to the database.
> > but
> > can someone tell me where i am going wrong when i want to insert a new
> > record
> > into the database. i hit the addbtn and i get the error:
> > Error System.IndexoutofRangeExceptionOccured in Sstem.data.dll
> > Additionalinformation:An SQL Parameter with parametername@Boothnumber is
> > not
> > contained by the SQLParameter collection
> > HELP PLEASE!!!!!!!!as u can propbably tell i am a newbie at this
>
>
>
- Previous message: Neal B. Scott: "Re: Error message and can not figure it out"
- In reply to: Neal B. Scott: "Re: Error message and can not figure it out"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|