Error message and can not figure it out
From: Triptaz (Triptaz_at_discussions.microsoft.com)
Date: 03/20/05
- Next message: Neal B. Scott: "Re: Error message and can not figure it out"
- Previous message: SP: "Re: How to insert to MS SQL from vb .net"
- Next in thread: Neal B. Scott: "Re: Error message and can not figure it out"
- Reply: Neal B. Scott: "Re: Error message and can not figure it out"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 19 Mar 2005 17:31:03 -0800
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
- Next message: Neal B. Scott: "Re: Error message and can not figure it out"
- Previous message: SP: "Re: How to insert to MS SQL from vb .net"
- Next in thread: Neal B. Scott: "Re: Error message and can not figure it out"
- Reply: Neal B. Scott: "Re: Error message and can not figure it out"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|