Problem with User Control...

G

Guest

Can someone please tell me why when I refer to a Sub in my User Control I
get the following error...

Error:..
Reference to a non-shared member requires an object reference

For some reason I can't find out why I am unable to refer to the following
sub...

Would be grateful for any help...


ASPX page...

cpncms_v1.UploadCnt.UploadData()

ASCX Page...

Sub UploadData()
'Dim ImageFile As System.Web.UI.HtmlControls.HtmlInputFile
Dim imgstream As Stream = ImageFile.PostedFile.InputStream
Dim imgdata(ImageFile.PostedFile.ContentLength) As Byte
imgstream.Read(imgdata, 0, ImageFile.PostedFile.ContentLength)


Dim MyConn As New
SqlConnection(ConfigurationSettings.AppSettings("strConn"))
Dim cmd As New SqlCommand("fileUpload", MyConn)
cmd.CommandType = CommandType.StoredProcedure

Dim titleparam As New SqlParameter("@fileTitle", SqlDbType.NVarChar,
255)
Dim descriptionparam As New SqlParameter("@fileDescription",
SqlDbType.NVarChar, 255)
Dim Ownerparam As New SqlParameter("@fileOwner", SqlDbType.NVarChar,
255)
Dim Officeparam As New SqlParameter("@officeID", SqlDbType.Int)
Dim typeparam As New SqlParameter("@fileType", SqlDbType.NVarChar,
100)
Dim dataparam As New SqlParameter("@fileData", SqlDbType.Image)

'Dim ImageTitle As System.Web.UI.WebControls.TextBox
'Dim fldOwner As System.Web.UI.WebControls.TextBox
'Dim fldDescription As System.Web.UI.WebControls.TextBox
'Dim ddlOffice As System.Web.UI.WebControls.DropDownList

titleparam.Value = ImageTitle.Text
descriptionparam.Value = fldDescription.Text
Ownerparam.Value = fldOwner.Text
Officeparam.Value = ddlOffice.SelectedIndex
typeparam.Value = ImageFile.PostedFile.ContentType
dataparam.Value = imgdata

cmd.Parameters.Add(titleparam)
cmd.Parameters.Add(descriptionparam)
cmd.Parameters.Add(Ownerparam)
cmd.Parameters.Add(Officeparam)
cmd.Parameters.Add(typeparam)
cmd.Parameters.Add(dataparam)

MyConn.Open()
cmd.ExecuteNonQuery()
MyConn.Close()
End Sub
 
M

Martin

Hi Tim,

You have to create an instance of the class first so that you can reference
the object.

if you want to referenece the object like you are doing it at the moment you
have to make it a shared method and then you will not need an instance
variable in order to referenece it.

HTH

cheers

martin.
 
G

Guest

Thanks for the reply!

I'm kind of new to this so I was wondering if you could explain how I create
an instance of the class so I can reference it!

Thanks...
 

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

Similar Threads

Shared Sub 3
Progress Bar help 3
User Control... HELP??? 3
USER CONTROL... ARHHHH 2
Problems understanding User Control??? 4
USER CONTROL PROBLEMS... 0
Large File Upload Probelm... 2
Array with SQLParameters 1

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top