Hi Everyone,
I am developing 1 desktop application to my friend office,in that application i can store multiple images and i can retrieve the information for the same..My issue here is after retrieving the information when i click on update button I'm getting runtime exception i.e (Empty path is not legal exception)..
Here is the code which I wrote under updatebutton method: - public partial class CustomerDetails : Form
-
{
-
-
string imageloc = "";
-
string imageloc1 = "";
-
string imageloc2 = "";
-
string imageloc3 = "";
-
string imageloc4= " ";
-
public static Byte[] Imagesave(string imagelocation)
-
{
-
byte[] img = null;
-
/*Empty path is not legal error*/ FileStream fs = new FileStream(imagelocation, FileMode.Open, FileAccess.Read);
-
BinaryReader br = new BinaryReader(fs);
-
img = br.ReadBytes((int)fs.Length);
-
fs.Close();
-
br.Close();
-
return img;
-
}
-
private void btnupdateinfo_Click(object sender, EventArgs e)
-
{
-
-
string scn = ConfigurationManager.ConnectionStrings["Myconn"].ConnectionString;
-
using (SqlConnection cn = new SqlConnection(scn))
-
{
-
using (SqlCommand cmd = new SqlCommand("SP_UpdateInfo", cn))
-
{
-
try
-
{
-
-
-
cmd.CommandType = CommandType.StoredProcedure;
-
-
cmd.Parameters.AddWithValue("@Hp_Number", tbhpnum.Text);
-
cmd.Parameters.AddWithValue("@Customer_Name", tbcusnam.Text);
-
cmd.Parameters.AddWithValue("@Customer_Contact_Number", tbcusmblno.Text);
-
cmd.Parameters.AddWithValue("@Guarantor_Name", tbguanam.Text);
-
cmd.Parameters.AddWithValue("@Guarantor_Contact_Number", tbguamblno.Text);
-
cmd.Parameters.AddWithValue("@Hp_Date", DateTime.Parse(tbhpdat.Text));
-
cmd.Parameters.AddWithValue("@Customer_Address", tbcusadd.Text);
-
cmd.Parameters.AddWithValue("@Vehicle", tbveh.SelectedItem.ToString());
-
cmd.Parameters.AddWithValue("@Vehicle_Model", tbvehmod.SelectedItem.ToString());
-
cmd.Parameters.AddWithValue("@Vehicle_Number", tbvehnum.Text);
-
cmd.Parameters.AddWithValue("@Chasis_Number", tbchanum.Text);
-
cmd.Parameters.AddWithValue("@Engine_Number", tbengnum.Text);
-
cmd.Parameters.AddWithValue("@FC_Date", DateTime.Parse(tbfcdat.Text));
-
cmd.Parameters.AddWithValue("@Insurance_Date", DateTime.Parse(tbinsdat.Text));
-
cmd.Parameters.AddWithValue("@Insurance_Amount", Convert.ToInt32(tbinsamt.Text));
-
cmd.Parameters.AddWithValue("@Paid_Amount", Convert.ToInt32(tbpaiamt.Text));
-
cmd.Parameters.AddWithValue("@Paid_Date", DateTime.Parse(tbpaidat.Text));
-
cmd.Parameters.AddWithValue("@Vehicle_Pic",Imagesave(imageloc));
-
cmd.Parameters.AddWithValue("@Customer_Pic", Imagesave(imageloc1));
-
cmd.Parameters.AddWithValue("@Guarantor_Pic", Imagesave(imageloc2));
-
cmd.Parameters.AddWithValue("@Documents_Pic", Imagesave(imageloc3));
-
cmd.Parameters.AddWithValue("@Insurance_Pic", Imagesave(imageloc4));
-
-
if (cn.State != ConnectionState.Open)
-
cn.Open();
-
-
int count = cmd.ExecuteNonQuery();
-
if (count == 1)
-
{
-
MessageBox.Show(count.ToString() + "Customer(s) Record(s) has Updated Successfully .", "Succes", MessageBoxButtons.OK);
-
}
-
-
-
}
-
-
catch (SqlException ex)
-
{
-
MessageBox.Show(ex.ToString());
-
-
}
-
finally
-
{
-
if (cn.State == ConnectionState.Open)
-
cn.Close();
-
}
-
}
-
}
-
-
}
3 2628
please set your image location should be save
I'm directly saving all the images into Database,in that case I didn't set path instead of that converting all the images into byte format before saving into database.
You're trying to open a file using a blank string on that line.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Matthias Ludwig |
last post by:
I'm trying to create a directory on the web server with a
vb.net code:
....
Dim dirName As String = "w:\filepath\images"
If Not Directory.Exists(dirName) Then...
|
by: billrdio |
last post by:
I am trying to make a JavaScript animation of real-time images - i.e.
images that will periodically change on the server. The problem I am
having is that the JavaScript animation I have created is...
|
by: Magnus Blomberg |
last post by:
Hello!
When loading a path with spaces to Image.ImageURL from an SQL database, the
picture is not shown.
The path in the Image becomes Xxxxxx%2520xxx and is not working. In another
application...
|
by: Alan Silver |
last post by:
Hello,
I have the following line of code in a script...
litMsg.Text = Server.MapPath("/");
where litMsg is an ASP.Net Literal control. When I try and run this
page, I get the error ...
...
|
by: Steve Amey |
last post by:
Hi all
I am having a problem when I am updating my database. I am using a
strong DS and the PK column is an Identity column, but when I am udating
my database I am getting the exception 'Column...
|
by: Chas Stapleton |
last post by:
I have recently uninstalled VB5 and installed vb.net 2002. In working on an
application, I attempted to add a picturebox and add an image... I
immediately received an "empty path name is not...
|
by: delusion7 |
last post by:
I'm not really sure I'm going about my problem the right way or not. What I want to to is have a save button, bring up the save dialog, and save a report from reportViewer(.rdlc) in .pdf format.
...
|
by: JR |
last post by:
System exception messages in VS2005 are given in the local language.
Sometimes it is nice, but often it is quite inconvenient - try looking up
MSDN or Google with a localized message!
So, after...
|
by: ranjith konnoju |
last post by:
hi,
i am getting an exception while populating the data in the datagrid.
am getting the values into datatable and binding it to the datagrid but it is not
displaying the data and giving...
|
by: rosaryshop |
last post by:
I'm working a jewelry/rosary design web site at http://www.rosaryshop.com/rosariesAndKits2.php.
As the user makes selections, it updates images of various parts, giving them a preview of the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |