TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Marvin Gapuz
NA
85
6.1k
System.NullReferenceException: 'Object reference not set to
Feb 23 2019 8:45 AM
if (strFilePath == "")
{
if (ImageByteArrays.Length != 0)
ImageByteArrays = new byte[] { };
}
else
{
Image temp = new Bitmap(strFilePath);
MemoryStream strm = new MemoryStream();
temp.Save(strm, System.Drawing.Imaging.ImageFormat.Jpeg);
ImageByteArrays = strm.ToArray();
}
if (sqlcon.State == ConnectionState.Closed)
{
sqlcon.Open();
SqlCommand sqlcmd = new SqlCommand("UPDATE tblMobileProduct SET ProductName=@pname,Brand=@brand,ExpandalbeMemory=@expandablememory,OStype=@ostype,Depth=@depth,PakageKG=@pakagekg,Display=@display,CPUspeed=@cpuspeed,USBtype=@usbtype,SimSize=@simsize,MPtype=@mptype,CNtech=@cntech,BatCapacity=@batcapacity,ModelNum=@modelnum,Descrip=@descrip,nimages=@nimage,Images=@image WHERE ProductName=@pname", sqlcon);
sqlcmd.Parameters.AddWithValue("@pname", txtPname.Text.Trim());
sqlcmd.Parameters.AddWithValue("@brand", cmbBrand.Text.Trim());
sqlcmd.Parameters.AddWithValue("@expandablememory", txtExmem.Text.Trim());
sqlcmd.Parameters.AddWithValue("@ostype", cmbOStype.Text.Trim());
sqlcmd.Parameters.AddWithValue("@depth", txtDepth.Text.Trim());
sqlcmd.Parameters.AddWithValue("@pakagekg", txtPkg.Text.Trim());
sqlcmd.Parameters.AddWithValue("@display", txtDisplay.Text.Trim());
sqlcmd.Parameters.AddWithValue("@cpuspeed", txtCPUspeed.Text.Trim());
sqlcmd.Parameters.AddWithValue("@usbtype", txtUSBtype.Text.Trim());
sqlcmd.Parameters.AddWithValue("@simsize", txtSimSize.Text.Trim());
sqlcmd.Parameters.AddWithValue("@mptype", txtMPtype.Text.Trim());
sqlcmd.Parameters.AddWithValue("@cntech", txtCNtech.Text.Trim());
sqlcmd.Parameters.AddWithValue("@batcapacity", txtBatCapacity.Text.Trim());
sqlcmd.Parameters.AddWithValue("@modelnum", txtModelNum.Text.Trim());
sqlcmd.Parameters.AddWithValue("@descrip", txtDescription.Text.Trim());
sqlcmd.Parameters.AddWithValue("@nimage", txtImage.Text.Trim());
sqlcmd.Parameters.Add("@image", ImageByteArrays);
sqlcmd.ExecuteNonQuery();
sqlcon.Close();
MessageBox.Show("Updated Successfully!");
reset();
btnSave.Enabled = false;
btnAdd.Visible = false;
btnUpload.Enabled = true;
System.NullReferenceException: 'Object reference not set to an instance of an object.'
ImageByteArrays was null.
Hello Please Help. Why is this not working whenever I try to update.
Reply
Answers (
3
)
how to mark as read only the last row of DataGridView ?
how can i pass links of use in asp.net closed by firewall