日期:2014-05-18  浏览次数:20537 次

想写成从数据库提出来的 怎么写呀
var pics = 'assets/images/banner/banner_i_1.jpg|assets/images/banner/banner_i_2.jpg|assets/images/banner/banner_i_3.jpg|assets/images/banner/banner_i_4.jpg|assets/images/banner/banner_i_5.jpg'

------解决方案--------------------
VB.NET code

    Private Function LoadImages() As String
        Dim _db As New SQLHelp '创建数据库连接
        Dim _Str As String = "" '定义一个空的字符串变量
        Dim _dt As Data.DataTable = _db.DataTable("SELECT [path] FROM [Table]") '从数据表获取数据
        If _dt.Rows.Count > 0 Then '判断数据是否为空,避免程序报错
            For i As Integer = 0 To _dt.Rows.Count - 1 '循环组合字符串
                If _Str = "" Then
                    _Str = _dt.Rows(i)("path")
                Else
                    _Str &= "|" & _dt.Rows(i)("path")
                End If
            Next
            Return "picc='" & _Str & "'" '组合成需要的字符串格式并输出
        Else
            Return ""
        End If
    End Function