Apache Ignite ODBC and ADODB Recordset problem fetching data - odbc

i try to fetch records from Apache Ignite inmemory database via Microsoft Access 2016 32-Bit and Apache Ignite 32-Bit ODBC-driver with default settings. OS is Windows 10.
Import as a linked table does not work so i tried via ADODB-Class.
Connection.Open and Recordset.Open works and i can see all columns (ID and NAME) of sample table CITY in the Recordset. But when i try to fetch the first record with MoveFirst or MoveNext, i get the error 'specified attribute is not supported'. I tried the same with CursorLocation=adUseClient and the error message changes to 'wrong parameter'. Default Provider is MSDASQL.1. Is this the correct Provider? Any idea how to fetch records with ADODB?
Code
`
Public Sub QueryIgnite()
Dim ADOrs As ADODB.Recordset
Dim ADOcon As ADODB.Connection
Set ADOcon = New ADODB.Connection
ADOcon.ConnectionString = "DSN=Apache-Ignite-DSN"
'ADOcon.CursorLocation = adUseClient
ADOcon.Open
Set ADOrs = New ADODB.Recordset
ADOrs.Open "select * from city", ADOcon, adOpenForwardOnly
ADOrs.MoveNext
Debug.Print ADOrs.Fields("NAME")
ADOrs.Close
ADOcon.Close
End Sub
`
Thank you in advance.
Regards.
Guido Clesius

A ticket on apache.org is created to fix the bug. See https://issues.apache.org/jira/browse/IGNITE-18210

Related

Parameterizing sql in asp

I'm not terribly familiar with asp, but I have one project with a page of it.
<%
'declare the variables
Dim Connection
Dim ConnString
Dim Recordset
Dim SQL
Dim userName
userName = Request.Form("userName")
'define the connection string, specify database driver
ConnString="JJJJJ"//connection information
'declare the SQL statement that will query the database
SQL = "SELECT info AS Lunch, "
SQL = SQL & "FROM dbo.AgentActivityLog WHERE UserId = '" & userName & "'
'create an instance of the ADO connection and recordset objects
Set Connection = Server.CreateObject("ADODB.Connection")
Set Recordset = Server.CreateObject("ADODB.Recordset")
'Open the connection to the database
Connection.Open ConnString
'Open the recordset object executing the SQL statement and return records
Recordset.Open SQL,Connection
'first of all determine whether there are any records
If Recordset.EOF Then
Response.Write("No records returned.")
Else
'process record
Next
Recordset.MoveNext
Loop
End If
'close the connection and recordset objects to free up resources
Recordset.Close
Set Recordset=nothing
Connection.Close
Set Connection=nothing
%>
How do I parameterize the username? I have no way to debug, no knowledge of how this language works, so whatever I tried failed and I have no idea why.
I would suggest you look at the Answer on following link as it will fill in the answers you seek:
VBA, ADO.Connection and query parameters
From the code provided critical missing piece is the ADODB.Command for the SQL to actually be run and to add the parameter the query you would :
Set Param = Command.CreateParameter("#userid",adVarChar,adParamInput)
Param.Value = userName
Command.Paramters.Append Param

MS Access to SQL Server connection

I'm using MS Access as my database, my hosting is not supporting this, and I need to know how to convert MS Access to SQL Server connection string?
This my code of data connection:
'--------------- ole parameters -------------------
Dim olecommand As Data.OleDb.OleDbCommand
Dim oledataadaptor As Data.OleDb.OleDbDataAdapter
Dim odbcDataSet As System.Data.DataSet
Sub populate_dataset_Access_accdb_test(ByRef ds As DataSet, ByVal sql As String)
Dim myDataConnection As New OleDbConnection(ConfigurationManager.ConnectionStrings("myodbc").ConnectionString)
olecommand = New OleDb.OleDbCommand
olecommand.CommandText = sql
odbcDataSet = New System.Data.DataSet
olecommand.Connection = myDataConnection
myDataConnection.Open()
oledataadaptor = New OleDbDataAdapter(sql, myDataConnection)
oledataadaptor.Fill(ds)
myDataConnection.Close()
End Sub
Sub insert_dataset_Access_accdb_test(ByVal sql As String)
Dim myDataConnection As New OleDbConnection(ConfigurationManager.ConnectionStrings("myodbc").ConnectionString)
olecommand = New OleDb.OleDbCommand
olecommand.CommandText = sql
odbcDataSet = New System.Data.DataSet
olecommand.Connection = myDataConnection
myDataConnection.Open()
olecommand = New OleDbCommand(sql, myDataConnection)
olecommand.ExecuteNonQuery()
myDataConnection.Close()
End Sub
Sub cr_ds(ByRef ds As DataSet, ByVal sql As String, ByVal tablename As String)
Dim myDataConnection As New OleDbConnection(ConfigurationManager.ConnectionStrings("myodbc").ConnectionString)
olecommand = New OleDb.OleDbCommand
olecommand.CommandText = sql
odbcDataSet = New System.Data.DataSet
olecommand.Connection = myDataConnection
myDataConnection.Open()
oledataadaptor = New OleDbDataAdapter(sql, myDataConnection)
oledataadaptor.Fill(ds, tablename)
myDataConnection.Close()
End Sub
Thank you in advance
As Steve Wellens pointed out, you miss some basic things here. Since your host does not support your data source type (MS Access), changing your connection string is not enough. You have to use a data store supported by your hosting service. I suppose that Microsoft SQL Server is one of them, but you have to verify it by contacting your hosting service administration support.
Regarding the transfer of data between MS Access and MS SQL Server, you could get some guidance here.
Regarding the MS SQL Server connection strings, you could get some help from this post but you have to verify the availability of the MS SQL Server database with your hosting service.
Hope I helped!
You can't just change an Access connection string to an SQL connection string and have things work. You would have to port your data From Access to the SQL Server.
I think it is more likely that when you deploy your Access database to the server, the path is different. You probably need to modify the config file to point to to where the Access file is on the server.

Ado connection to SQL Server Compact Edition 4.0

I want to connect to SQL Server Compact Edition 4.0 from an old asp-classic site but i always get the error:
"Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified. "
I tried
sCon = "Data Source=c:\temp\sqlcompact.sdf;Encrypt Database=True;Password=testtest;Persist Security Info=False;"
and
Update:
Error: Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done
sCon = "Provider=Microsoft.SQLSERVER.CE.OLEDB.4.0;Data Source=c:\temp\sqlcompact.sdf;Password=testtest;"
without any success.
Is it generally possible to connect to SQL Server CE 4.0 from ADO?
Update:
Example Code
Open Connection:
dim sCon
dim gCON : set gCON=CreateObject ("ADODB.Connection")
sCon = "Provider=Microsoft.SQLSERVER.CE.OLEDB.4.0;Data Source=c:\temp\sqlcompact.sdf;Pwd=testtest;"
gCon.ConnectionString = sCon
gCon.Open
gCon.Close
Yes, you can connect to SQL CE 4 via ADO.
Set Cnxn = CreateObject("ADODB.Connection")
Set cmd = CreateObject("ADODB.Command")
strCnxn = "Provider=Microsoft.SQLSERVER.CE.OLEDB.4.0;" & _
"Data Source=C:\nw40.sdf;"
Cnxn.Open strCnxn
cmd.ActiveConnection = Cnxn
cmd.CommandText = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES"
While Not pRS.EOF
WScript.Echo pRS(0)
pRS.MoveNext
wend
For password protected files, use:
strCnxn = "Provider=Microsoft.SQLSERVER.CE.OLEDB.4.0;" &
_ "Data Source=C:\nw40.sdf;ssce:database password=secret"
Try with the the following provider instead, saw somewhere it's being used with success:
sCon = "Provider=Microsoft.SqlServer.Mobile.OleDb.3.0;Data Source=c:\temp\sqlcompact.sdf;Password=testtest;"
If no luck, can you create System DSN successfully? If so, create one then use it in the ASP code.

error on ExecuteNoQuery()

i'am trying to update a row in a table using :
command.ExecuteNoQuery()
it's not giving me an error but it's not updating the row
This is my code :
Dim req As String = "Update Table Set Id= 5"
Dim cmd As New OleDb.OleDbCommand(req, connect())
cmd.ExecuteNonQuery()
disconnect()
thanks
Make sure that ID isn't an IDENTITY column.
the problem is that the query was too slow with MS Access.
Now it's working fine MS SQL Server.

Microsoft ODBC driver for Oracle Syntax error or access violation (-2147217900)

I have a large VB program that connects to Oracle database.
strCn = "Driver={Microsoft ODBC for Oracle};" & _
"SERVER=PSPROD;"
Set Cn = New ADODB.Connection
Cn.ConnectionString = strCn
Cn.CursorLocation = adUseNone
Cn.Open
There are many users of my program so I have a table that contains each user's login name and their access rights to the various tables. I create a recordset of all users when the program is started and then select USERNAME and GRANTED_ROLE from the record set where USERNAME and PASSWORD are found. I use a "Set role 'GRANTED_ROLE' identified by 'password'" statment and Cn.Execute statement to set up the user's access rights. This is all done in a Module.
On a form, I want to call a Stored Procedure that will SELECT, INSERT and UPDATE information into another schema's tables. I am able to call and run the stored procedure when I create a new connection to the database with this code:
Dim cmd5040 As ADODB.Command
Dim conn5040 As ADODB.Connection
Dim param5040 As ADODB.Parameter
Set conn5040 = New ADODB.Connection
conn5040 = "Driver={Microsoft ODBC for Oracle};" & _
"SERVER=PSPROD; UID=XXXXXXX; PWD=XXXXXXXX"
conn5040.Open
Set cmd5040 = New ADODB.Command
With cmd5040
.ActiveConnection = conn5040
.CommandType = adCmdStoredProc
.CommandText = "S4115040_IMPORT_NEWBIDITEMSPES.S4115040_CheckTime"
.Parameters.Append .CreateParameter(, adInteger, adParamInputOutput, 5)
.Parameters.Append .CreateParameter(, adVarChar, adParamInputOutput, 400)
End With
cmd5040(0) = 0
cmd5040(1) = ""
cmd5040.CommandTimeout = 300
cmd5040.Execute
conn5040.Close
However, I get the error message "-2147217900 [Microsoft][ODCB driver for Oracle]Syntax error or access violation" when I attempt to use the same connection ('Cn') when the program first started. My code is:
Dim cmd5040 As ADODB.Command
Dim param5040 As ADODB.Parameter
Set cmd5040 = New ADODB.Command
With cmd5040
.ActiveConnection = Cn
.CommandType = adCmdStoredProc
.CommandText = "S4115040_IMPORT_NEWBIDITEMSPES.S4115040_CheckTime"
.Parameters.Append .CreateParameter(, adInteger, adParamInputOutput, 5)
.Parameters.Append .CreateParameter(, adVarChar, adParamInputOutput, 400)
End With
cmd5040(0) = 0
cmd5040(1) = ""
cmd5040.Execute
I have worked with my DBA. She has given me direct grants and direct execute privliges and I am still get the error message.
What am I doing wrong? Should I be able to use the original connection to run a stored procedure? Or must I create a second connection?
edit: on reviewing your code, I notice that the original connection Cn specifies the driver and the server name whereas the second connection conn5040 specifies the driver, server name, user and password.
Therefore, it may be that the stored procedure you are calling requires a user and password which the original cn connection does not specify
Original answer:
Make sure that the variable cn is still in scope when you try to use it. If it is declared in a module then it should be declared outside of any Sub or Function and, if other modules should be able to access it, it should be declared as Public
Option Explicit
Public cn as ADODB.Connection
Sub foo()
...
Presuming that cn is still in scope, you could examine the State property of the object which cn references to see if the Connection is still open.
If (cn.State = adStateClosed) Then
' we have a problem
...

Resources