คือว่าหนูต้องการเอาคอลัม coorx กับ coory มาตัดแล้วจับคู่กัน หลักที่ 1 ของ a กับ หลักที่ 1 ของ B
แต่ว่าหนูเขียนออกมาได้แค่ข้อมูลอันเดียว ต้องการทำหลายๆเรคคอด ต้องเขียนโค้ดเพิ่มเติมตรงไหนบ้างไหนคะ
Code (VB.NET)
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim connect2 As New SqlConnection(sql_db)
Dim cmdsql2 As New SqlCommand
Dim rdr1 As SqlDataReader
cmdsql2.Connection = connect2
cmdsql2.CommandText = "select [ID],[landid],[coorx],[coory],[canetype],[area] from map_plot where landid = '01-251995-03'"
cmdsql2.CommandType = CommandType.Text
' cmdsql2.Parameters.AddWithValue("@supcode", )
Dim str1, str2 As String
Dim strArr(), str2Arr() As String
Try
connect2.Open()
rdr1 = cmdsql2.ExecuteReader()
If rdr1.Read() Then
str1 = rdr1("coorx")
str2 = rdr1("coory")
strArr = str1.Split(",")
str2Arr = str2.Split(",")
'
Dim lst As New List(Of KeyValuePair(Of String, String))
For i As Integer = 0 To strArr.Length - 1
lst.Add(New KeyValuePair(Of String, String)(strArr(i), str2Arr(i)))
Next
Repeater1.DataSource = lst
Repeater1.DataBind()
End If
Catch ex As Exception
' MsgBox(ex.ToString)
connect2.Close()
connect2.Dispose()
End Try
End Sub
Public Class ItemClass
Public Property Item1() As String
Get
Return m_Item1
End Get
Set
m_Item1 = Value
End Set
End Property
Private m_Item1 As String
Public Property Item2() As String
Get
Return m_Item2
End Get
Set
m_Item2 = Value
End Set
End Property
Private m_Item2 As String
End Class
Code (VB.NET)
Dim ls As New List(Of ItemClass)()
Code (VB.NET)
For i As Integer = 0 To strArr.Length - 1
ls.Add(New ItemClass() With { _
Key .Item1 = strArr(i), _
Key .Item2 = str2Arr(i) _
})
Next
น่าจะไปต่อได้ครับ
Date :
2015-08-31 15:55:01
By :
mr.win
No. 2
Guest
Code (VB.NET)
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim connect2 As New SqlConnection(sql_db)
Dim cmdsql2 As New SqlCommand
Dim rdr1 As SqlDataReader
cmdsql2.Connection = connect2
cmdsql2.CommandText = "select [ID],[landid],[coorx],[coory],[canetype],[area] from map_plot where landid like '%251995%' "
cmdsql2.CommandType = CommandType.Text
Try
connect2.Open()
rdr1 = cmdsql2.ExecuteReader()
While rdr1.Read()
lst.Add(New KeyValuePair(Of String, String)(rdr1("landid"), rdr1("canetype")))
add_str_list(rdr1("coorx"), rdr1("coory"))
End While
Repeater1.DataSource = lst
Repeater1.DataBind()
Catch ex As Exception
connect2.Close()
connect2.Dispose()
End Try
End Sub
Function add_str_list(ByVal a As String, ByVal b As String) As String
Dim strArr(), str2Arr() As String
strArr = a.Split(",")
str2Arr = b.Split(",")
For i As Integer = 0 To strArr.Length - 1
lst.Add(New KeyValuePair(Of String, String)(strArr(i), "," & str2Arr(i)))
Next
Return 0
End Function
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim connect2 As New SqlConnection(sql_db)
Dim cmdsql2 As New SqlCommand
Dim rdr1 As SqlDataReader
cmdsql2.Connection = connect2
cmdsql2.CommandText = "select [ID],[landid],[coorx],[coory],[canetype],[area] from map_plot where landid like '%251995%' "
cmdsql2.CommandType = CommandType.Text
Try
connect2.Open()
rdr1 = cmdsql2.ExecuteReader()
While rdr1.Read()
lst.Add(New KeyValuePair(Of String, String)(rdr1("landid"), rdr1("canetype")))
add_str_list(rdr1("coorx"), rdr1("coory"))
End While
Repeater1.DataSource = lst
Repeater1.DataBind()
Catch ex As Exception
connect2.Close()
connect2.Dispose()
End Try
End Sub
Function add_str_list(ByVal a As String, ByVal b As String) As String
Dim strArr(), str2Arr() As String
strArr = a.Split(",")
str2Arr = b.Split(",")
For i As Integer = 0 To strArr.Length - 1
lst.Add(New KeyValuePair(Of String, String)(strArr(i), "," & str2Arr(i)))
Next
Return 0
End Function