PSS ID Number: 179022
Article Last Modified on 1/9/2003
Alter table pubs.dbo.pub_info add pub_name char(10) null,
whattime timestamp null
After you have run the above successfully in ISQL-W, run the following
by itself in ISQL-W:
Update pub_info set pub_name= "MSPress" where pub_id= "0736"
The code above will insert a timestamp field in the table and a value
in that field for the first record where the pub_id is 0736. If the
first record has a different pub_id value, use that value instead. This
will also place a value in the timestamp field.
CREATE PROCEDURE updat_pub_info @id char(4), @mytext text,
@pname char(10), @thyme timestamp
AS
update pub_info
set pr_info= @mytext,
pub_name= @pname
where pub_id= @id and tsequal(@thyme,whattime)
Option Explicit
Dim en As rdoEnvironment
Dim rs As rdoResultset
Dim cn As rdoConnection
Dim qr As rdoQuery
Dim sqlstr As String
Dim mytime As Variant
Private Sub Command1_Click()
sqlstr = "select pub_id, pub_name, pr_info, whattime from pub_info"
Set rs = cn.OpenResultset(sqlstr, rdOpenKeyset, _
rdConcurRowVer, rdExecDirect)
mytime = rs(3) 'needed to send the timestamp back to the procedure
End Sub
Private Sub Command2_Click()
rs.Edit
rs(1) = "testing" 'update the char field, change in 2nd instance
End Sub
Private Sub Command3_Click()
rs(2) = "mmmmmmmmmm" 'update the text field,change in 2nd instance
End Sub
Private Sub Command4_Click()
rs.Update
End Sub
Private Sub Command5_Click()
'On Error GoTo myerr 'uncomment to trap error
Set qr = cn.CreateQuery _
("", "{call updat_pub_info(?,?,?,?)}")
qr.rdoParameters(0).Direction = rdParamInput
qr.rdoParameters(1).Direction = rdParamInput
qr.rdoParameters(2).Direction = rdParamInput
qr.rdoParameters(3).Direction = rdParamInput
qr(0) = "0736"
qr(1) = "QUE"
qr(2) = "This is a third text field"
qr(3) = mytime 'variant type will compare to timestamp
qr.Execute
Exit Sub
On Error GoTo 0
myerr:
MsgBox Err.number
End Sub
Private Sub Command6_Click()
If Not (rs Is Nothing) Then
rs.Close
End If
cn.Close
Unload Me
End Sub
Private Sub Form_Load()
Set en = rdoEnvironments(0)
'change dsName to the data source name in your odbc administrator
Set cn = en.OpenConnection(dsName:="mymachine", _
Prompt:=rdDriverNoPrompt, _
Connect:="uid=sa;pwd=;database=PUBS;")
Command1.Caption = "resultset"
Command2.Caption = "edit char field"
Command3.Caption = "edit text field"
Command4.Caption = "update"
Command5.Caption = "update stor proc"
Command6.Caption = "quit"
End Sub
Additional query words: blob multiuser kbVBp500 kbVBp600 kbdse kbDSupport kbVBp
Keywords: kbprb KB179022
Technology: kbAudDeveloper kbVB500 kbVB500Search kbVB600 kbVB600Search kbVBSearch kbZNotKeyword2 kbZNotKeyword6