You can refer this link
[WebMethod]
[ScriptMethod]
public static Slide[] GetImages()
{
List<Slide> slides = new List<Slide>();
string constr = ConfigurationManager.ConnectionStrings["ConString"].ConnectionString;
using (SqlConnection conn = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("SELECT FileName,FilePath FROM FileTable", conn))
{
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
{
DataTable ds = new DataTable();
da.Fill(ds);
foreach (DataRow row in ds.Rows)
{
slides.Add(new Slide
{
Name = row[0].ToString(),
Description = Path.GetFileNameWithoutExtension(row[0].ToString()) + " Description.",
ImagePath = row[1].ToString()
});
}
}
}
}
return slides.ToArray();
}
SQL
CREATE TABLE [dbo].[FileTable](
[ID] [int] IDENTITY(1,1) NOT NULL,
[FileName] [varchar](50) NOT NULL,
[FilePath] [varchar](200) NOT NULL
) ON [PRIMARY]
GO
Image