I'm migrating data from Microsoft Access 2013 to Oracle-SQL Developer(Oracle client 12.1). I'm using ODBC link, I can migrate my tables but the conversion of the data types isn't correct. In fact, all the data types re converted to VARCHAR2(eg. NUMBER(Access)becomes VARCHAR2(Oracle)).
How can I fix it ? Is there any way to convert types explicitly ?
Thank you
You may be able to do it in two steps, first migrating to MS SQL server. You can use the free Express Edition and the free Access to MS SQL migration tool which allows you to manually map MS Access types to MS SQL Server types. It should be fairly easy to find out what MS SQL Server types migrate to in Oracle-SQL so you can make the necessary mappings on the fist step.
There are several approaches.
One approach is to build the table structure in Oracle (use Oracle design tools). You then link to that oracle table in Access.
You can now run a append query in Access to send the table from Access to Oracle. The result will be data type mappings of your choice. And you can even build such a append query with the Access query bulder.
Another approach is to send the data from Access to Oracle. You don’t mention now how you are doing this. But, most data types will and do get translated correctly if you use the transfer database command with this format:
Sub SendToSQL()
Dim strLocalTable As String
Dim strSQLTable As String
Dim strSQLDataBase As String
strSQLDataBase = "test3"
strLocalTable = "tblFood"
strSQLTable = "tblFood"
Dim strODBC As String
strODBC = "ODBC;DRIVER=SQL Server;SERVER=ALBERTKALLAL-PC\SQLEXPRESS;Trusted_Connection=Yes;DATABASE="
strODBC = strODBC & strSQLDataBase
DoCmd.TransferDatabase acExport, "ODBC Database", _
strODBC, acTable, strLocalTable, strSQLTable
End Sub
The above should send + create the table in Oracle, and you should retain “most” of the correct data types when you do the above.
Of course the above example uses a SQL server connection string, and you would of course replace the above connection string with a oracle one.
Related
This code works when the connection is made to an accdb database:
Dim customer = connection.Query(Of Klantgegevens)("Select Actief,Onderhoudscontract From Klantgegevens Where Klantnummer=#Idx", New With {.Idx = customerId}).SingleOrDefault
But the code below gives the error about the Idx parameter when the connection is made to a SQL server database that has a table with the same structure:
Dim customer = connection.Query(Of Klantgegevens)("Select Actief,Onderhoudscontract From [dbo.Klantgegevens] Where Klantnummer=#Idx", New With {.Idx = customerId}).SingleOrDefault
What is going wrong here? I had hoped that by using Dapper I would be able to write database agnostic code. But it seems that is not the case!
If you are using an ODBC/OLEDB connection, then my first suggestion would be: move to SqlClient (SqlConnection). Everything should work fine with SqlConnection.
If you can't do that for some reason - i.e. you're stuck with a provider that doesn't have good support for named parameters - then you might need to tell dapper to use pseudo-positional parameters. Instead of #Idx, use ?Idx?. Dapper interprets this as an instruction to replace ?Idx? with the positional placeholder (simply: ?), using the value from the member Idx.
This is also a good fix for talking to accdb, which has very atypical parameter usage for an ADO.NET provider: it allows named parameter tokens, but all the tokens all replaced with ?, and given values from the positions of the added parameters (not via their names).
I have two databases with the same schema inside a Sql 2008 R2 Server, of which names are Database1 and Database2. I connected and performed queries on the Database1, and then changed to Database2 to fetch my entities using the following code
this.ConnectionString = "Server=TestServer; Database=Database2;Trusted_Connection=true";
using (IDataAccessAdapter adapter = new DataAccessAdapter(this.ConnectionString))
{
var entities = new EntityCollection<T>();
adapter.FetchEntityCollection(entities, null);
return entities;
}
(The connection string was set before executing the code).
I debugged the application and looked at the value of the connection string, it pointed to the Database2.
However, when I executed the above code, the result was return from the Database1. And if I looked at SQL Profiler, the statement was executed against Database1.
So, could anyone know what was going on? Why the query was executed against the Database1, not Database2.
PS: If I used the above connection string with plain ADO.NET, I was able to retrieve data from Database2.
Thanks in advance.
I have figured out what was going on. The reason was: by default LLBL Gen Pro uses fully qualified names like [database1].[dbo].[Customer] to access database objects, and the catalog is specified when generating entities. So you can't access objects just by changing the connection string.
Hence, to change to another database you have to override the default catalogue by using following code
var adapter= new DataAccessAdapter(ConnectionString, false,
CatalogNameUsage.ForceName, DbName)
{CommandTimeOut = TenMinutesTimeOut};
More information can be found at the following link
I used leaves stru2mysql.prg and vfp2mysql_upload.prg to create a .sql dump file from DBF's. I connect to mysql database from vfp using ODBC.I KNOW how upload the sql dump file but i need to automate the whole process i.e after creating the dump file,my visual foxpro program can upload the dump file without a third party(automatically). I thought of using the source command but that needs to be run in mysql prompt.The assumption here is that my end users dont know how to import(which most of them dont).Please advice on how i can automate importation of sql file to mysql database.thank you
I think what you are looking for are the various SQL* functions in Foxpro. See the VFP help or MSDN on SQLCONNECT (or SQLSTRINGCONNECT), SQLEXEC, and SQLDISCONNECT functions to get you started. Microsoft provided good examples on each in the documentation.
You may also want to use FILETOSTR to get the output from Leafe's programs into a string for the SQLEXEC function.
Here's the steps I use to take data from a Visual FoxPro Database and upload to a MySql Database. These are all put into a custom method on a form, which is fired by a command button. For example the method would be 'uploadnewdata' and I pass parameters for whichever data tables I need
1) Connect to the Server - I use MySql ODBC
2) Validate the user (this uses a SQLEXEC to pull the correct matching record for a users tables
IF M.WorkingDatabase<>-1
nRetVal=SQLEXEC(m.WorkingDatabase,"SELECT * FROM users", "csrUsersOnServer")
SELECT csrUsersOnServer
SELECT userid,FROM csrUsersOnServer;
WHERE ALLTRIM(UPPER(userid))=ALLTRIM(UPPER(lcRanchUser));
AND ALLTRIM(UPPER(lcPassWord))=ALLTRIM(UPPER(lchPassWord));
INTO CURSOR ValidUsers
IF _TALLY>=1
ELSE
=MESSAGEBOX("Your Premise ID Does Not Match Any Records On The Server","System Message")
RETURN 0
ENDIF
ELSE
=MESSAGEBOX("Unable To Connect To Your Database", "System Message")
RETURN 0
ENDIF
3) Once that is successful I create my base cursor (this is the one I'm sending from)
4) I then loop through that cursor creating variable for the values in the fields
5) then using the SQLEXEC, and INSERT INTO, I update each record
6) once the program is finished processing the cursor, it generates a messagebox with the 'finished' message and control returns to the form.
All the user has to do, is select the starting table and enter their login information
I am trying to create an ACCESS DB at run time and register is as a DSN in ODBC.ini using the following code:
BOOL fCreated;
fCreated = SQLConfigDataSource(NULL,ODBC_ADD_DSN,
"Microsoft Access Driver (*.mdb)",
"CREATE_DB=.\\ATest.mdb General\0" );
printf("Database created : %d\n",fCreated);
BOOL ReturnResult = SQLConfigDataSource (NULL, ODBC_CONFIG_DSN,
"Microsoft Access Driver (*.mdb)",
"DSN=TESTDSN_DSN\00DBQ=.\\ATest.mdb\ \
00FIL=MSAccess\00Description=TESTDSN_database\00UID=\00");
printf("Database registered : %d\n",ReturnResult);
The first statement returns 1 showing that the DB is created but the second one returns 0 indicating that it could not be registered as a DataSourceName in ODBC.ini. Can anyone please tell me why is this happening because everything like path and name is correct.
It was already mentioned in the comments to the question, but I wanted to provide an answer with some more information:
Instead of creating a DSN by code on some machine, it's probably easier to link the tables DSN-less (programmatically) in the client that will access the database.
If the client is MS Access as well, you can do it with DoCmd.TransferDatabase:
Dim SourceDB As String
Dim SourceTable As String
Dim LocalTable As String
'path to the database that contains the original table
SourceDB = "C:\Your_Database.mdb"
'name of the original table in the source database
SourceTable = "Original_Table"
'name of the linked table in the local database
LocalTable = "Linked_Table"
DoCmd.TransferDatabase acLink, "Microsoft Access", SourceDB, acTable, SourceTable, LocalTable
I'm trying to create an SSIS 2008 Data Source View that reads from an Ingres database via the ODBC driver for Ingres. I've downloaded the Ingres 10 Community Edition to get the ODBC driver, installed it, set up the data access server and a DSN on the server running SSIS.
If I connect to the SQL Server 2008 Database Engine on the server running SSIS, I can retrieve data from Ingres over the ODBC DSN by running the following command:
SELECT *
FROM OPENROWSET( 'MSDASQL'
, 'DSN=IngresODBC;UID=testuser;PWD=testpass'
, 'SELECT * FROM iitables')
So I am quite sure that the ODBC setup is correct.
If I try the same query with SQL Server style bracketed identifier quotes, I get an error, as Ingres doesn't support this syntax.
SELECT *
FROM OPENROWSET( 'MSDASQL'
, 'DSN=IngresODBC;UID=testuser;PWD=testpass'
, 'SELECT * FROM [iitables]')
The error is "[Ingres][Ingres 10.0 ODBC Driver][Ingres 10.0]line 1, Unexpected character '['.".
What I am finding is that I get the same error when I try to add tables from Ingres to an SSIS Data Source View. The initial step of selecting the ODBC Provider works fine, and I am shown a list of tables / views to add. I then select any table, and try to add it to the view, and get "ERROR [5000A] [Ingres][Ingres 10.0 ODBC Driver][Ingres 10.0]line 3, Unexpected character '['.".
Following Ed Harper's suggestion of creating a named query also seems to be stymied. If I put into my named query the following text:
SELECT *
FROM "iitables"
I still get an error: "ERROR [5000A] [Ingres][Ingres 10.0 ODBC Driver][Ingres 10.0]line 2, Unexpected character '['".
According to the error, the query text passed by SSIS to ODBC was:
SELECT [iitables].*
FROM
(
SELECT *
FROM "iitables"
)
AS [iitables]
It seems that SSIS assumes that bracket quote characters are acceptable, when they aren't. How can I persuade it not to use them? Double quotes are acceptable.
I don't know a way to change the quoted identifier, but you may be able to get around this by creating a blank DSV (click through the DSV wizard without adding any tables) then, rather than adding the tables to the DSV directly, adding them as named queries (right-click the empty DSV and select "New Named Query".
This enables you control the text of the query yourself, and set your own identifiers.
(I'm making this suggestion based on SSIS 2005, but I think 2008 works in a similar way.)