update employee set fname=" Paolo''''f"
where emp_id='PMA42628M'
update employee set fname=" Paolo''f"
where emp_id='PMA42628M'
---- 法式以下:
---- 起首把后面的函数到场。
---- 在窗体的通用中声明以下变量:
Dim cnn1 As ADODB.Connection '毗连
Dim mycommand As ADODB.Command '号令
Dim rstByQuery As ADODB.Recordset '了局集
Dim strCnn As String '毗连字符串
Private Sub Form_Load()
Set cnn1 = New ADODB.Connection '生成一个毗连
strCnn = "driver={SQL Server};" & _
"server=ZYX_pc;uid=sa;pwd=PCDC;database=pubs" '
没有体系数据源利用毗连字符串
'strCnn = "DSN=mydsn;UID=sa;PWD=;"
'DATABASE=pubs;Driver={SQL Server};SERVER=gzl_pc" '
假如体系数据源MYDSN指向PUBS数据库,也能够如许用
cnn1.Open strCnn, , , 0 '翻开毗连
End Sub
Private Sub Command1_Click() '演示字符处置
Dim i As Integer
Dim j As Integer
Set parm = New ADODB.Parameter
Set mycommand = New ADODB.Command
Dim str As String
str = Combo1.Text
str = ProcessStr (str)
mycommand.ActiveConnection = cnn1 '
指定该command 确当前举动毗连
mycommand.CommandText = " select * from
employee where fname = '" & str & "'"
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
'Set rstByQuery = mycommand.Execute()
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
Private Sub Command2_Click()'参数办法
Dim i As Integer
Dim j As Integer
Set parm = New ADODB.Parameter
Set mycommand = New ADODB.Command
' parm_jobid.Name = "name1" this line can be ommited
parm.Type = adChar '参数类型
parm.Size = 10 '参数长度
parm.Direction = adParamInput '参数偏向,输出或输入
parm.Value = Combo1.Text '参数的值
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 '设置第一行的题目,用域名填充