SQL Server中单引号的两种处理技巧
2007-05-09 09:25:18 来源:WEB开发网mycommand.Parameters.Append parm '加入参数
mycommand.ActiveConnection = cnn1 '
指定该command 的当前活动连接
mycommand.CommandText = " select *
from employee where fname =? "
mycommand.CommandType = adCmdText '表明command 类型
Set rstByQuery = New ADODB.Recordset
Set rstByQuery = mycommand.Execute()
i = 0
Do While Not rstByQuery.EOF
i = i + 1 ' i 中保存记录个数
rstByQuery.MoveNext
Loop
MSFlexGrid1.Rows = i + 1 '动态设置MSFlexGrid的行和列
MSFlexGrid1.Cols = rstByQuery.Fields.count + 1
MSFlexGrid1.Row = 0
For i = 0 To rstByQuery.Fields.count - 1
MSFlexGrid1.Col = i + 1
MSFlexGrid1.Text = rstByQuery.Fields.Item(i).Name
Next '设置第一行的标题,用域名填充
i = 0
rstByQuery.Requery
Do While Not rstByQuery.EOF
i = i + 1
MSFlexGrid1.Row = i '确定行
For j = 0 To rstByQuery.Fields.count - 1
MSFlexGrid1.Col = j + 1
MSFlexGrid1.Text = rstByQuery(j) '添充所有的列
Next
rstByQuery.MoveNext
Loop '这个循环用来填充MSFlexGrid的内容
End Sub
查询部分可以用存储过程以提高处理效率,减低网络流量。本程序在NT WORKSTATION 4.0 SP4、SQL SERVER 7.0 上调试通过。
更多精彩
赞助商链接