0

How can i read images from folder "images" and her name in the database using asp.net vb code this is the code i use.

   Dim conn As SqlConnection
   Dim cmd As SqlCommand
   Dim cmdString As String = ("select TOP 20 * from tbl_news order by db_id desc ")
   conn = New SqlConnection("Data Source=.\sqlexpress;AttachDbFilename=C:\Users\m7md\Documents\Visual Studio 2008\Projects\AlAkhbar\AlAkhbar\App_Data\Database1.mdf;Integrated Security=True;User Instance=True")
   cmd = New SqlCommand(cmdString, conn)
   conn.Open()
   Dim dr As SqlDataReader = cmd.ExecuteReader

   While (dr.Read)
       Response.Write("<div id=title>")
       Response.Write("<img src='images/db_img')  />")
       Response.Write("</div>")
       Response.Write("<div id=title>")
       Response.Write(dr("db_title"))
       Response.Write("<br/>")
       Response.Write("<br/>")
       Response.Write("</div>")
       Response.Write("<div id=sumury>")
       Response.Write(dr("db_sumury"))
       Response.Write("</div>")
       Response.Write("<div id=readmore>")
       Response.Write("<a href=readmore.aspx?id=" & dr("db_id").ToString & "> Readmore</a>")
       Response.Write("</div>")
       Response.Write("<hr/>")

   End While
1
  • 1
    "_ plz help me_" - we don't appreciate begging here. Also, you have many errors in your HTML. You can't have two elements with the same id, for instance. You should also read about using the Repeater or DataList controls. Commented Dec 25, 2013 at 17:17

1 Answer 1

2

You need to create an image handler. You can find more information here:

Sign up to request clarification or add additional context in comments.

2 Comments

plz more details in coding
stackoverflow.com/questions/21877/… The sample code is there. You can use @FlySwat sample code. I did not find fair copying over their answer here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.