Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
0
Reply
Object reference not set to an instance of an object in asp.
Reylin Markose
May 17 2018 6:08 AM
133
Reply
this is my code...
--------------------
if (!fupImage.HasFile)
{
// File was sent
string stdid = Session["StdId"].ToString();
int length = fupImage.PostedFile.ContentLength;
if (length > 500 * 1024)
{
Response.Write("Ur image is too large");
}
else
{
byte[] pic = new byte[length];
//HttpPostedFile img = fupImage.PostedFile; img.InputStream.Read(pic, 0, length);
fupImage.PostedFile.InputStream.Read(pic, 0, length);
string res = std.StudentImageUpload(stdid, pic);
Response.Redirect("Dashboard.aspx");
}
}
else
{
// No file
}
this is my class function
-----------------------------
public string StudentImageUpload(string stdid,byte[] pic)
{
try
{
GetConnect();
SqlCommand cmd = new SqlCommand("insert into Std_Photo(StdId,Phto) values(@stdid,@photo)", SqlCon);
cmd.Parameters.AddWithValue("@stdid",stdid);
cmd.Parameters.Add("@photo", SqlDbType.Binary).Value=pic;
string res = cmd.ExecuteNonQuery().ToString();
GetClosed();
return res;
}
catch (Exception ex)
{
throw ex;
}
}
--------------------------------
my problem is , executing time this line
int length = fupImage.PostedFile.ContentLength;
got error for Object reference not set to an instance of an object in asp.... how to solve this problem.?
Thanks in advnce.
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
0
)
Next Recommended Forum
Multiple Register Form class into a single login form class
How to deploy asp.net application?