首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

!使用存储过程datagrid不可编辑

2012-01-30 
求助!使用存储过程datagrid不可编辑.Private Sub Command1_Click()Dim strS As StringDim adoconn As New

求助!使用存储过程datagrid不可编辑.
Private Sub Command1_Click()

Dim strS As String
Dim adoconn As New ADODB.Connection
Dim adocomm As New ADODB.Command
Dim ReturnValue As Integer
Dim rs As New ADODB.Recordset

adoconn.ConnectionString = "DRIVER=SQL Server;SERVER=(local);UID=sa;PWD=sa;DATABASE=CHENWEI"
adoconn.Open
adoconn.CursorLocation = adUseClient

Set adocomm.ActiveConnection = adoconn
adocomm.CommandText = "info_test"
adocomm.CommandType = adCmdStoredProc

rs.CursorLocation = adUseClient
rs.CursorType = adOpenKeyset
rs.LockType = adLockPessimistic
Set rs = adocomm.Execute

Set DataGrid1.DataSource = rs
DataGrid1.Refresh
DataGrid1.AllowUpdate = True

End Sub


[解决办法]

VB code
Set rs = adocomm.Execute'这句提前试试,如果还是不行,只能用open语句查询,因为Execute方法返回的 Recordset 对象始终为只读、仅向前的游标rs.CursorLocation = adUseClientrs.CursorType = adOpenKeysetrs.LockType = adLockPessimistic 

热点排行