关于调用数据库中的图片的问题 再做一个网站,显示文章的页面做好了,显示图片的功能也能实现,但是有一个问题就是我在文章中显示的图片是我上传的所有图片,而不是和相关文章对应的图片。我在数据库中已经建立了文章和图片所在表的一对多的关系,有人说我可能数据连接的代码写的不对才导致的将全部图片都显示出来了,请各位指教,万分感激!!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 1.对应关系可能没写好2.SQL语句确实有问题没有代码,这样想的~ <asp:Repeater id="repeater3" runat="server"> <HeaderTemplate> <table border="0" width="95%" cellpadding=0 cellspacing=0 align=center> </HeaderTemplate> <ItemTemplate> <tr> <td align=center> <image src="<%# Container.DataItem("picaddr") %>" width="180" height="115" border=0 /> <font color="gray">[<%#Container.DataItem("picmemo")%>]</font> </td> </ItemTemplate> <SeparatorTemplate> </SeparatorTemplate> <FooterTemplate> </table> </FooterTemplate> </asp:Repeater> <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/Blog.mdb" SelectCommand="SELECT [PicMemo], [LogID], [PicAddr] FROM [UserPhoto]"> </asp:AccessDataSource>这是repeater的代码Sub BindPhoto() Dim StrCnn As String Dim Cnn As OleDbConnection Dim Cmd As OleDbDataAdapter Dim DTable As New DataTable Dim Sql As String StrCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("blog.mdb") Cnn = New OleDbConnection(StrCnn) If Session("username") = "" Then theName = "hyh1203" Else theName = Trim(Session("username")) End If PathStr = Trim(theName) & "/photo/" Sql = "select top 3 id,'" & Trim(PathStr) & "'+ picaddr as picaddr,picmemo from userphoto order by ddate desc" Cnn.Open() Cmd = New OleDbDataAdapter(Sql, Cnn) Cmd.Fill(DTable) repeater3.DataSource = DTable repeater3.DataBind() Cnn.Close() End Sub这是链接数据库的代码,请各位帮忙看看病,谢谢啦~ GridView控件里的删除如何弹出一个提示(是否)的对话框 答题 关于Attributes.Add 无法显示,求高人解答 请教一个SQL语句 求一个分页代码,GridView的,谢谢 高分求:asp.net实现Mysql数据库备份与还原 js访问Repeater内的控件 asp.net中有什么控件可以不显示在界面中,但又可以保留值? session 丢失问题 分页存储过程在查询分析器中执行效率很快,但程序加载的时候需要很久呢?高人指路啊!! js如何给页面传参数,页面如何接受参数以及从数据库返回数据生成连接 请问一个页面呈现顺序的问题
2.SQL语句确实有问题
没有代码,这样想的~
<HeaderTemplate>
<table border="0" width="95%" cellpadding=0 cellspacing=0 align=center>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td align=center>
<image src="<%# Container.DataItem("picaddr") %>" width="180" height="115" border=0 />
<font color="gray">[<%#Container.DataItem("picmemo")%>]</font>
</td>
</ItemTemplate>
<SeparatorTemplate>
</SeparatorTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/Blog.mdb"
SelectCommand="SELECT [PicMemo], [LogID], [PicAddr] FROM [UserPhoto]">
</asp:AccessDataSource>
这是repeater的代码
Sub BindPhoto()
Dim StrCnn As String
Dim Cnn As OleDbConnection
Dim Cmd As OleDbDataAdapter
Dim DTable As New DataTable
Dim Sql As String
StrCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("blog.mdb")
Cnn = New OleDbConnection(StrCnn)
If Session("username") = "" Then
theName = "hyh1203"
Else
theName = Trim(Session("username"))
End If
PathStr = Trim(theName) & "/photo/"
Sql = "select top 3 id,'" & Trim(PathStr) & "'+ picaddr as picaddr,picmemo from userphoto order by ddate desc"
Cnn.Open()
Cmd = New OleDbDataAdapter(Sql, Cnn)
Cmd.Fill(DTable)
repeater3.DataSource = DTable
repeater3.DataBind()
Cnn.Close()
End Sub
这是链接数据库的代码,请各位帮忙看看病,谢谢啦~