2010-10-05 92 views
0
Dim rs As New ADODB.Recordset 



strConnectionString = "Provider=SQLOLEDB.1;Integrated Security=True;Initial Catalog=Hospital_ABC;Data Source=ITEM-47791\SQLEXPRESS;Persyst Security Info=False;Command Properties='Command Time Out=45'" 





Set connexion = New ADODB.Connection 

connexion.ConnectionString = strConnectionString 

connexion.ConnectionTimeout = 30 

connexion.Open strConnectionString 

rs.Open "insert into student_info(name,rollNo,age, class,address,assigned_teacher)values('name',rollno,age,'cls','add','assteac')", connexion 

我使用這個代碼中插入值客棧我的表,,,但我得到的錯誤是 - 運行時錯誤(多步OLEDB產生的操作錯誤,請檢查每個OLEDB狀態值,如果有的話) 請檢查錯誤在VB6.0連接字符串

回答

1

看看這個是什麼錯茨艾倫代碼.....:

http://support.microsoft.com/kb/269495

它說:

The following are two possible causes of this error:

  1. In the registry, under the key for an OLE DB provider's CLSID, there may be an entry named OLEDB_SERVICES. If the OLE DB provider that is used to make the ADO connection does not have the OLEDB_SERVICES entry, and ADO tries to set up a property that is not supported by the provider, the error occurs. For more information about this registry entry, see the "Resolution" section.

  2. If OLEDB_SERVICES entry exists but there is a problem in the ADO connection string, the error occurs.

0

試試這個:

rs.Open "insert into student_info(name,rollNo,age,class,address,assigned_teacher) values('n',1,1,'c','a','a')", connexion 

對我來說,當一個數據太長字段的錯誤通常發生。您可以通過每次更新一個字段來查找故障(更新名稱,然後更新名稱和編號,名稱和編號以及年齡等),以進一步排除故障。

1

不要在連接字符串中使用它 Persyst Security Info = False; Command Properties ='Command Time Out = 45'