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 2625
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: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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,...
| |