| Author |
Topic |
|
arganum
Starting Member
4 Posts |
Posted - 2009-07-01 : 16:12:34
|
| What I have been working is an application that will allow the user to upload an image to a web server. I used asp:FileUpload control to do this. Anyway, what I need to do now is save, at the same time as the upload, the path to that image in SQL. How do I go about doing this? Is there an example that I can look at?Thank you for any help that you can give me |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
arganum
Starting Member
4 Posts |
Posted - 2009-07-01 : 16:25:58
|
| With that INSERT INTO statement, what FilePath will be saved? What I need is the path to the image in the server with my hosting company. I am sorry that I am not good at explaining this out. My newbieness is showing I'm afraid. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
arganum
Starting Member
4 Posts |
Posted - 2009-07-01 : 16:46:57
|
| The name of the folder where the images are being saved is watercolorImages. So that path would need to be:watercolorImages/'whatever the image name is'How can I grab that name and add it to the path as it is being saved? |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
arganum
Starting Member
4 Posts |
Posted - 2009-07-01 : 16:57:09
|
| I am working in Visual Studio 2008 with C#. I am using SQL Express 2008 as well. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-07-01 : 17:02:45
|
It's a long way to the top if you wanna yak'n'roll  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
rajdaksha
Aged Yak Warrior
595 Posts |
Posted - 2009-07-02 : 07:38:24
|
| Am not sure ... what u expect...tryprivate void cmdSave_Click(object sender, EventArgs e){ try { //Read Image Bytes into a byte array byte[] imageData = ReadFile(txtImagePath.Text); //Initialize SQL Server Connection SqlConnection CN = new SqlConnection(txtConnectionString.Text); //Set insert query string qry = "insert into ImagesStore (OriginalPath,ImageData) _ values(@OriginalPath, @ImageData)"; //Initialize SqlCommand object for insert. SqlCommand SqlCom = new SqlCommand(qry, CN); //We are passing Original Image Path and //Image byte data as sql parameters. SqlCom.Parameters.Add(new SqlParameter("@OriginalPath", (object)txtImagePath.Text)); SqlCom.Parameters.Add(new SqlParameter("@ImageData", (object)imageData)); //Open connection and execute insert query. CN.Open(); SqlCom.ExecuteNonQuery(); CN.Close(); //Close form and return to list or images. this.Close(); } |
 |
|
|
rajdaksha
Aged Yak Warrior
595 Posts |
Posted - 2009-07-02 : 07:39:30
|
| Hi arganumTo store an image in to sql server, you need to read image file into a byte array. Once you have image data in byte array, you can easity store this image data in sql server using sql parameters |
 |
|
|
|