I have a website which I want to run on IIS Windows XP , but on the login page when I try to connect I get this error from file (Access.asp)
Here is the code of file :
<%# Language=VBScript %>
<!--#include file="PerformClear.asp"-->
<!--#include file="expire.vbs"-->
<%'Déclarations de toutes les variables de cette page
dim login, password, numu
dim sql, rs , conn
'Response.Redirect("PleaseWait.htm")
login = Trim(Replace(Request.Form ("login"),"'","''"))
password = Trim(Replace(Request.Form ("password"),"'","''"))
'Response.write (nom)
if (login<>"") and (password<>"") then
SQL = "SELECT * FROM Cadre WHERE Utilisateur='" & login & "' & pw='" & password & "'"
Set rs = Session("conn").Execute(SQL)
If not rs.eof then 'alors l'utilisateur est bien identifié'
session("nom")=rs("utilisateur") 'pour se rappeler de l'utilisateur
session("num")=rs("code_cadre")
numu=rs("code_cadre")
rs.Close
set rs=nothing
Response.Redirect "."
else
rs.Close
set rs=nothing
Response.Redirect "erreur.asp?Code=1"
end if
rs.close
set rs = nothing
else
Response.Redirect("erreur.asp?Code=1")
end if
%>
The error i get is :
ADODB.Connection error '800a0e78' Operation Failed and Non authorized
because Object Closed
Please help I'm lost.
You should not store the ADODB connection in the Session object, this forces thread affinity which is harmful and is very inefficient.
So long as you use the same connection string it will be pooled automatically, connect and close new connections as and when you need them in the page.
Additionally your using an ampersand here instead of AND:
"SELECT * FROM Cadre WHERE Utilisateur='" & login & "' & pw='" & password & "'"
Change to:
"SELECT * FROM Cadre WHERE Utilisateur='" & login & "' AND pw='" & password & "'"
Related
Please your help, I have the error -2147217865 in Microsoft.ACE.OLEDB provider reading a SharePoint list with VBA, where the Microsoft Access database engine could not find the object. Sometimes it connects without problems, but at other times it generates the error with the same query.
Set cnt = New ADODB.Connection
Set rst = New ADODB.Recordset
mySQL = "SELECT * FROM [" & SPListName & "];"
With cnt
.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;WSS;IMEX=1;RetrieveIds=Yes;" & _
"DATABASE=" & SERVERUrl & ";" & _
"LIST={" & SPListID & "}"
.Open
End With
rst.Open mySQL, cnt, adOpenDynamic, adLockOptimistic
I think the problem is with authentication in Sharepoint. Not if you can include the username and password in the connection string.
Would GREATLY appreciate help on this issue.
I was recently forced to install "Microsoft 365 Apps Update - Semi-Annual Enterprise Channel (Preview) Quality Update for x86 based Edition Version 2202 (Build 14931.20494). When I did, VBA program button code (on a form) that I wrote that allows user to get data from SharePoint causes EXCEL to crash no matter how I try to trap or ignore errors. As soon as the "End Sub" line of button code is executed, up comes a "Microsoft EXCEL has stopped working / Restart the program" window and EXCEL crashes when I click it. Interesting this is that the data IS returned from SharePoint and displayed on another form just fine. To get the SharePoint data, I have an Access file (.accdb) set up that defines the SharePoint list. Below are the pertinent pieces of code:
Const SQLENGSHAREPOINTCONNECTION = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source = C:\MORGAN\MACROS\ENG_SHAREPOINT_db.accdb"
** SETUP stuff **
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim StrSql As String
StrSql = "SELECT A.[Material], A.[Status], D.[Name], B.[Name], C.[Name], A.[Priority], A.[ID], A.[Date Requested]," & _
" A.[Brief ECRDescription], A.[Date Started], A.[Where In Process], A.[Priority]" & _
" from (([Engineering Change Requests (ECRs)] A" & _
" Left Join [UserInfo] B On A.[Product Owner] = B.[ID])" & _
" Left Join [UserInfo] C On A.[Principle Engineer] = C.[ID])" & _
" Left Join [UserInfo] D On A.[AssignedTo] = D.[ID]" & _
" where A.[Material] like '%" & myCollection(1) & "%'" & _
" and Left(A.[Status],2)< 25 "
** OPEN CONNECTION stuff **
cn.Open SQLENGSHAREPOINTCONNECTION
Set rs = cn.Execute(StrSql)
** PROCESSING stuff **
If Not (rs.BOF And rs.EOF) Then
Do While Not rs.EOF
If rs.Fields(0) <> "" Then
theDisplay = Left("Material: " & rs![Material] & vbcrlf & theDisplay
End If
rs.MoveNext
Loop
End If
** CLOSE CONNECTION stuff **
If Not (rs Is Nothing) Then
If (rs.State = 1) Then
rs.Close
End If
Set rs = Nothing
End If
cn.Close
Turns out the update package I installed was a "preview" and sent out to a small number of users for review. The actual update package that will officially go out does not have this issue. So the issue turns out to not be an issue. Both packages did not mention any changes to EXCEL which is odd.
Can anyone please help me understand why Microsoft.Ace.OLEDB.16.0 doesn't work on Windows 10 x64 with Office 2016 x86?
I get runtime error -2147467259 (80004005) when the connection to OLEDB 16.0 is opened using the following code:
Public Sub ValidityDateCheck_SRT_Templates()
NameFile = "x"
sConn = "Provider=Microsoft.ACE.OLEDB.16.0;WSS;IMEX=1;RetrieveIds=Yes;" & _
"DATABASE=" & sSHAREPOINT_SITE & ";" & _
"LIST=" & sDEMAND_ROLE_GUID_ML & ";"
Set cn = New ADODB.Connection
Set rst = New ADODB.Recordset
With cn
.ConnectionString = sConn
.Open '--> **HERE I GET THE ERROR**
End With
Rs = "SELECT * FROM [Template Library];"
rst.Open Rs, cn, adOpenStatic, adLockOptimistic
Do Until rst.EOF
If Left(rst![Name], InStr(1, rst![Name], "#") - 1) = TemplateID Then
NameFile = rst![Name]
On Error GoTo Skip
ActualVdate = rst![Validity Date]
TransVdate = rst![Transition Period End]
Exit Do
Else
rst.MoveNext
End If
Loop
Skip:
rst.Close
The interesant part is that in DEBUG, if I use 12.0 first and then change to 16.0 and save, it will open it. Then, if I reopen file, i get same error.
Please help me guys.
Are you using VBA? If so, please ensure you have enabled the Microsoft ActiveX Data Objects 6.1 Library on the reference menu.
Try this;
cn.Open "Provider=Microsoft.Ace.OLEDB.16.0;" & _
"Data Source=" & UserForm2.TextBox32.Text & ";Jet OLEDB:Database Password=1101010;Persist Security Info=False;"
I've recently upgraded to office 365 and now find myself attempting to use excel VBA to insert from an Excel sheet into an Access database. Here is the VBA code I'm trying to use:
Sub ExportDataToAccess()
Dim cn As Object
Dim strQuery As String
Dim myDB As String
Dim creditDate As Date
Dim regionalTeam As String
'Initialize Variables
creditDate = Worksheets("Treasury").Range("E20").Value
regionalTeam = Worksheets("Treasury").Range("e21").Value
myDB = "Y:\Credit DB\Credit.accdb"
Set cn = CreateObject("ADODB.Connection")
With cn
.Provider = "Microsoft.ACE.OLEDB.12.0" 'For *.ACCDB Databases
.ConnectionString = myDB
.Open
End With
strQuery = "INSERT INTO Credit ([creditDate], [regionalTeam]) " & "VALUES (""" & creditDate & """, " & regionalTeam & ");"
cn.Execute strQuery
cn.Close
Set cn = Nothing
End Sub
When I run this subroutine, I get the following error message:
Runtime error: No value given for one or more required parameter.
I've tried to Google the error message but didn't have much luck. Can anyone tell me where I have gone astray? I've also confirmed that creditDate and regionalTeam have valid values. I should add that the cn.Execute strQuery seems to be the offending code (highlighted).
Thanks for your input.
Format your date expression:
strQuery = "INSERT INTO Credit ([creditDate], [regionalTeam]) VALUES (#" & Format(creditDate, "yyyy\/mm\/dd") & "#, " & regionalTeam & ");"
or, if the team is text:
strQuery = "INSERT INTO Credit ([creditDate], [regionalTeam]) VALUES (#" & Format(creditDate, "yyyy\/mm\/dd") & "#, '" & regionalTeam & "');"
I have a macro in my excel workbook that updates a specific record in the access database related to the spreadsheet.
All works fine if the access database is closed. Problems arise if the database is open and a user is editing the specific record that the excel spreadsheet relates to.`
I get the following Error Message:
Error Number 2147467259:
The database has been paced in a state by user 'ADMIN' on
'LAPTOP' that prevents it from being opened or locked.
I have set the database form's Record Locks to 'No Record Locks' but this hasn't helped.
Any advice or help is greatly appreciated.
Cheers
Noel
Public Sub updateAccessRecord()
On Error GoTo ProcError
Dim subFuncName As String
subFuncName = "updateAccessRecord"
Dim conn As ADODB.Connection
Dim cmd As ADODB.Command
Dim rst As ADODB.Recordset
Dim dbName As String
Dim dbPath As String
Dim strCon As String
Dim recID As Long
Dim fieldVal As Double
Dim strSQL As String
fieldVal = Worksheets("House Claim").Cells(593, 10).Value
dbName = "claim-db.mdb"
dbPath = ThisWorkbook.Path & "\..\..\..\..\"
dbPath = dbPath & "\" & dbName
strSQL = "UPDATE tblInsClaimDet SET propSet=" & fieldVal & " WHERE ID=" & recID & ""
Set conn = New ADODB.Connection
With conn
.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & dbPath
.Open
End With
Set cmd = New ADODB.Command
With cmd
.ActiveConnection = conn
.CommandText = strSQL
End With
Set rst = cmd.Execute
Set rst = Nothing
conn.Close
Set conn = Nothing
ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure in " & subFuncName
Resume ExitProc
End Sub
It seems that you have not split the database into a front-end and a back-end. The problem goes away if you do. Ctrl+S is not for saving a record, that is Shift+Enter, it is for saving a database object, and so it seems it has the effect of throwing the database into design or development state.
On the macro side; have you tried opening your connection as read-only? Even though your Access user is not locking the record, he has a "read lock" on the record, thereby preventing an exclusive lock by excel. I'm thinking that if both users are only attempting only read access, you should be Ok; but if either one is doing read/write, then it will fail.
On your access form, you should also have:
Me.AllowAdditions = True
Me.AllowDeletions = False
Me.AllowEdits = False
The problem is probably not in your code. The error:
The database has been paced in a state by
Indicates that the database has been opened in an exclusive mode. You should check how you are opening the database.