I have saved a file to my sql server. I also have the name and path stored of the original file location. When the user clicks the button, I want the user to be able select a location to store the file. Right now I have this code but it saves whatever file I have to the same location and file name. The other problem is that I don't think this code descriminates on what in the Table it downloads. I will need to add some code that selects a certain row.
Code:SqlConnection con = new SqlConnection(blah blah); SqlDataAdapter da = new SqlDataAdapter("Select * from Images", con); SqlCommandBuilder MyCB = new SqlCommandBuilder(da); DataSet ds = new DataSet("MyImages"); byte[] MyData= new byte[0]; da.Fill(ds, "MyImages"); DataRow myRow; myRow=ds.Tables["MyImages"].Rows[0]; MyData = (byte[])myRow["imgField"]; int ArraySize = new int(); ArraySize = MyData.GetUpperBound(0); FileStream fs = new FileStream(@"C:\winnt\Gone Fishing2.BMP", FileMode.OpenOrCreate, FileAccess.Write); fs.Write(MyData, 0,ArraySize); fs.Close();




Reply With Quote