Click here to Skip to main content
15,886,422 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys

Problem 1:
Im doing a Windows Desktop (C#) Application and want to save an image path to a sql server 2008 database.

Problem 2:
Once its saved, to retrieve the path & display it on different forms.

Any help or website links would be appreciated. I've tried google & other websites but no help.

Kindest Regards
Posted

Just create a NVARCHAR field on sql server and pass the path through as a string.

using (SqlConnection con = new SqlConnection(strConnect))
    {
    con.Open();
    using (SqlCommand com = new SqlCommand("INSERT INTO myTable (imagePath) VALUES (@IM)", con))
        {
        com.Parameters.AddWithValue("@IM", @"C:\My Images\the name of the image.jpg");
        com.ExecuteNonQuery();
        }
    }
 
Share this answer
 
Thank you...

Having problems with

@"C:\My Images\the name of the image.jpg");

but im busy troubleshooting.

Regards
 
Share this answer
 
Comments
Dr.Walt Fair, PE 13-Aug-11 12:04pm    
What problem is it giving you?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900