Retrieving data from server

TaylorJW

New Member
My files are in folder and files path in database i want to display files from folder in gridview based on files path in database using asp.net.I am using following code:\[code\]protected void Page_Load(object sender, EventArgs e) { label3.Text = "hi" + Session["user"]; var userid =Session["user"]; DataTable dt = new DataTable(); string connection = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Quiz\saved games\documents\visual studio 2010\Projects\USpace\USpace\App_Data\uspace.mdf;Integrated Security=True;User Instance=True"; string strQuery = "select links from storage3 where username='"+userid+"'"; SqlCommand cmd = new SqlCommand(strQuery); SqlConnection con = new SqlConnection(connection); SqlDataAdapter sda = new SqlDataAdapter(); cmd.CommandType = CommandType.Text; cmd.Connection = con; try { con.Open(); sda.SelectCommand = cmd; sda.Fill(dt); gridview1.DataSource = dt; gridview1.DataBind(); } catch (Exception ex) { Response.Write(ex.Message); } //finally //{ // con.Close(); // sda.Dispose(); // con.Dispose(); //} }\[/code\] \[code\]<div> <asp:GridView ID="gridview1" runat="server" AutoGenerateColumns="False"> <Columns> <asp:ImageField DataImageUrlField="links" ControlStyle-Width="100" ControlStyle-Height = "100" HeaderText = "Preview Image" /> </Columns>\[/code\]here "links" is the column name in db...
 
Back
Top