Try
'得到姓名,工号
Dim wr As WebReference.EipUserServices = New WebReference.EipUserServices
Dim str_result As String = wr.GetUserTable '接收返回的XML文本
'将XML文本导入已实例化的Dataset
Dim myds As DataSet = New DataSet
Dim stringreadr As System.IO.StringReader = New System.IO.StringReader(str_result)
Dim xmltextrder As System.Xml.XmlTextReader = New System.Xml.XmlTextReader(stringreadr)
myds.ReadXml(xmltextrder)
Dim tt9 As String = "%" + Me.TextBox1.Text.Trim + "%"
'将工号读出来
mysql = "SELECT a.TableSort, b.BDName, a.UserCode, a.State "
mysql &= " FROM Not_Email a INNER JOIN BasicData b ON a.TableSort = b.BDCode"
mysql &= " WHERE (b.DataSort = 'A') AND ((b.BDName LIKE @BDName) OR (a.UserCode LIKE @UserCode)) ORDER BY a.TableSort"
mycomm = New SqlCommand(mysql, myconn1)
mycomm.Parameters.Add("@UserCode", tt9.Trim)
mycomm.Parameters.Add("@BDName", tt9.Trim)
myda = New SqlDataAdapter(mycomm)
ds.Tables.Clear()
myconn1.Open()
myda.Fill(ds, "T1")
Dim t3 As DataTable
Dim tr As DataRow
Dim i, j, k As Int16
t3 = New DataTable("t3")
For i = 0 To 5
t3.Columns.Add(New DataColumn("C" + i.ToString))
Next
'将记录T1写到对应的T3列中
For i = 0 To ds.Tables("T1").Rows.Count - 1
tr = t3.NewRow
tr(0) = ds.Tables("T1").Rows(i).Item(0)
tr(1) = ds.Tables("T1").Rows(i).Item(1)
tr(2) = ds.Tables("T1").Rows(i).Item(2)
tr(3) = ds.Tables("T1").Rows(i).Item(3)
t3.Rows.Add(tr)
Next
'扫描web 得到的用户表,将使用记录写入T3对应的行中
Dim gh As String
Dim rowno As Int16
For i = 0 To myds.Tables(0).Rows.Count - 1
gh = myds.Tables(0).Rows(i).Item(2) '工号
'在T3中查找名为mycode的会议室所在的行号,然后将从T2复制到T3
For j = 0 To t3.Rows.Count - 1
If t3.Rows(j).Item(2) = gh Then
If CStr(myds.Tables(0).Rows(i).Item(0)).Trim = "" Then
Else
t3.Rows(j).Item(4) = myds.Tables(0).Rows(i).Item(0)
End If
End If
Next
Next
Dim ii As Integer
' Dim i As Integer
ii = t3.Rows.Count
ii = ii Mod 20
If ii < 10 Then
For i = 0 To 10 - ii
t3.Rows.Add(t3.NewRow)
Next
End If
'将T3绑定到datagrid
Me.DataGrid1.DataSource = t3.DefaultView
Me.DataGrid1.DataBind()
myconn1.Close()
Catch ex As Exception
Me.Label1.Text = "出错了:<br>在读取数据库时出现异常,数据读取失败!<br>原因事:" + ex.Message
End Try
posted on 2005-11-14 13:45
萌芽的叶子 阅读(551)
评论(0) 编辑 收藏 引用 所属分类:
sql