VB COM DLL doesn't allow to update data from database using ADO
-
Hi, I'm creating a COM Dll using VB6, I created simple functions to make an update on a database, but it doesn't work, I'm using an ASP Page that succesfully create the object but gives me errors when I try to insert or update data (Also I tried creating the object from other VB Application but didn't work either, 'weird' but when I use this code on a EXE it works, but I need this in a COM Dll).
VB Dll Code
Public Function Save() Dim Cn As New ADODB.Connection Cn.ConnectionTimeout = 100 Cn.ConnectionString = "DBQ=test.mdb;" & _ "DRIVER={Microsoft Access Driver (*.mdb)};" & _ "DefaultDir=C:\My Docs\My Source Code\VB\ASP-COM Test;" & _ "UID=admin; PWD=;" Cn.Mode = adModeReadWrite Cn.Open Cn.Execute "INSERT INTO tests (test_value) VALUES ('test3')" Cn.Close Save = True End Function
ASP page code
<% Dim iTest Set iTest = Server.CreateObject("TestProject.Test") Response.Write iTest.Save %>
Like this it returns this errorError Type: Microsoft OLE DB Provider for ODBC Drivers (0x80004005) [Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query. /xue2/index.asp, line 6
I also tried using a RecordSet Object but gives this error:Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80004005) [Microsoft][ODBC Microsoft Access Driver] Cannot update. Database or object is read-only. /xue2/index.asp, line 6
Thanks if anyone can help! Vertigo -
Hi, I'm creating a COM Dll using VB6, I created simple functions to make an update on a database, but it doesn't work, I'm using an ASP Page that succesfully create the object but gives me errors when I try to insert or update data (Also I tried creating the object from other VB Application but didn't work either, 'weird' but when I use this code on a EXE it works, but I need this in a COM Dll).
VB Dll Code
Public Function Save() Dim Cn As New ADODB.Connection Cn.ConnectionTimeout = 100 Cn.ConnectionString = "DBQ=test.mdb;" & _ "DRIVER={Microsoft Access Driver (*.mdb)};" & _ "DefaultDir=C:\My Docs\My Source Code\VB\ASP-COM Test;" & _ "UID=admin; PWD=;" Cn.Mode = adModeReadWrite Cn.Open Cn.Execute "INSERT INTO tests (test_value) VALUES ('test3')" Cn.Close Save = True End Function
ASP page code
<% Dim iTest Set iTest = Server.CreateObject("TestProject.Test") Response.Write iTest.Save %>
Like this it returns this errorError Type: Microsoft OLE DB Provider for ODBC Drivers (0x80004005) [Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query. /xue2/index.asp, line 6
I also tried using a RecordSet Object but gives this error:Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80004005) [Microsoft][ODBC Microsoft Access Driver] Cannot update. Database or object is read-only. /xue2/index.asp, line 6
Thanks if anyone can help! VertigoHi I faced similar problems with {Microsoft Access Driver (*.mdb)}; provider try : OLEDB jet provider :
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;User Id=admin; Password=;"
and check http://www.connectionstrings.com [^]for more
-
Hi I faced similar problems with {Microsoft Access Driver (*.mdb)}; provider try : OLEDB jet provider :
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;User Id=admin; Password=;"
and check http://www.connectionstrings.com [^]for more
Oh!, thank you for your answer, I tried before the same connection string with no positive results :confused: , but I found the solution :), it was not big deal, it was nothing in the code, it was a problem with permissions in the IIS Configuration :wtf: (Not using Anonymous Access [chosen by default when you create a virtual directory], the correct one was using the Integrated Windows Authentication.). I lost a complete day in a such thing :(( but it happens :sigh: . Anyway, Thx for your help, Vertigo