Object reference not set to an instance of an object error

C

Chumley the Walrus

In an asp.net insert data script, I'm getting an Object reference not
set to an instance of an object error on the line that creates the
parameter for @sport. Not sure why, since I am inserting the field
name correctly in the sql insert statement:

'''''
Dim InsertCmd As String = "insert into tblArticles
(sport,articleheader) values (@sport,@articleheader)"

MyCommand.Parameters.Add(New SqlParameter("@Sport",
SqlDbType.VarChar, 50))
MyCommand.Parameters("@Sport").Value =
Server.HtmlEncode(sport.Value)
''''

Here is how I am tagging the input box:

<input type="text" id="sport" value="" runat="server">


????
Thanks in advance
Chumley
 
G

Guest

You may want to make sure that an instance of your control was created in the code behind. It is usually collapsed at the top of your code behind it should looks something like

protected withevents sport as system.web.ui.webcontrols.textbox

Todd Meister
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top