将服务器端循环变量传递给Javascript

时间:2011-12-29 06:27:35

标签: javascript vb.net

  

可能重复:
  Assign Vb.net loop variable values to javascript Array

我正在尝试将服务器端循环变量分配给客户端阵列,但是它给出了错误。我的服务器端和客户端代码如下所示。

 <%  Dim con As New OleDbConnection
        con = New OleDbConnection("Data Source=sml; User ID=sml; Password=sml; provider=OraOLEDB.Oracle")
        con.Open()
        Dim cmd As OleDbCommand = New OleDbCommand("Select STA_NAME, GPS_ONE from GPS", con)

        Dim ds As New DataSet
        Dim I As Long
        Dim da As New OleDbDataAdapter(cmd)
        da.Fill(ds, "GPS")
        For I = 0 To ds.Tables("GPS").Rows.Count - 1
            I = ds.Tables("GPS").Rows.Count - 1
            Dim GPS As String = ds.Tables("GPS").Rows(I).Item("GPS_ONE")
            Dim STATION As String = ds.Tables("GPS").Rows(I).Item("STA_NAME")
        Next I


        con.Close()%>

现在我想传递

Dim GPS As String = ds.Tables(“GPS”)。行(I).Item(“GPS_ONE”)   Dim STATION As String = ds.Tables(“GPS”)。行(I).Item(“STA_NAME”)

到客户端javascript

var GPS_A = '<%=GPS %>'
var GPS = new array();
[
new google.maps.LatLng(GPS_A)
];

但我在第

行收到编译错误
   var GPS_A = '<%=GPS %>'

错误是“未声明GPS”

请告诉我我到底错过了什么,我该怎么办

0 个答案:

没有答案