求助!使用存储过程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
[解决办法]
Set rs = adocomm.Execute'这句提前试试,如果还是不行,只能用open语句查询,因为Execute方法返回的 Recordset 对象始终为只读、仅向前的游标rs.CursorLocation = adUseClientrs.CursorType = adOpenKeysetrs.LockType = adLockPessimistic