I'm building a website for a client that uses a FoxPro desktop database system.
The data that should be shared between the database and website is essentially a list of members (fairly flat structure: their contact details, a few flag fields etc)
They'd like any changes that are made to these member details to be automatically synched through to the website (mysql database). It doesn't need to be totally instant but the process needs to be easy.
My question is what are the simplest approaches that could be used here? they are willing to compromise a bit to save development time/cost.
Is there an easy way for FoxPro could talk directly to my online MySQL database?
Could FoxPro create an XML or CSV type file and pass it to a web script? (which i then parse and update MySQL with)
Any suggestions appreciated.
You could use either ODBC or OLE DB from Visual FoxPro. Using ODBC is typically fairly straightforward.
Use SQLConnect or SQLStringConnect to connect to the server.
Some connection string examples show what might work for the SQLStringConnect call.
Then call SQLExec to run some queries.
Foxpro has an intrinsic function CURSORTOXML, which will take a table and convert it to XML
It is fairly well documented in the help files, but here is a simple example of its use
LOCAl lcXML,lnRecords
use my_table
lnRecords=CURSORTOXML('my_table','lcXML',0)
? lnRecords
? lcXML
Hope this helps
Try this:
Create a Shared Folder on your Web Server.
Create a CSV of your Data and save on the Shared Folder.
Create a Cron Jobs/ Scheduler to parse and dump the data to your Mysql.
This works for me.
Get the odbc driver from here: https://dev.mysql.com/downloads/connector/odbc/
You may also need Microsoft Visual C++ 2010 Redistributable Package (x86) vcredist_x86.exe
Use this code to establish the mysql connection
PUBLIC server,port,db,uid,pw
server="" & use mysql ip
port="" & port mysql is open on
db="" & db name
uid="" & user anme
pw="" & password
mysql = SQLSTRINGCONNECT('Driver={MySQL ODBC 5.3 Unicode Driver};Server=' + server + ';Port=' + port + ';Database=' + db + ';uid=' + uid + ';Pwd=' + pw + ';',.T.)
IF VARTYPE(mysql) == 'L' OR m.mysql < 0
MESSAGEBOX('MySQL Connection Failed. Logging will be disabled for this session.',16,'MySQL Error',3500)
ENDIF
Here's an example to do an insert into a mysql table. I use it for logging user actions into mysql.
IF VARTYPE(mysql) != 'L' AND m.mysql >= 0
SQLPREPARE (;
m.mysql;
,'INSERT INTO logging (computer,operator,application,program,version,action) VALUES (;
?COMPUTERNAME ;
,?OPERATOR ;
,?thisApplication ;
,?thisProgram ;
,?thisVersion ;
,?logMessage;
);';
)
SQLEXEC(m.mysql)
ENDIF
You can use XML for sending information to web application by HTTP REQUEST.
to create/read XML in foxpro, you can use CURSORTOXML/XMLTOCURSOR.
In your web application, you can create a web service to receive/send XML data.
If you want another data type, you can use JSON data. Use QDFOXJSON https://qdfoxjson.codeplex.com/
I'd say your quickest/easiest bet is probably to do the following via a nightly script:
export your FoxPro data to XML
push the data into the MySQL database using something like Python or Java
In the long run though, you're probably better off totally ditching FoxPro after the initial import ;)
Related
is there any way using SSIS (or any MSSQL Server features) to automatically run a stored procedure and have the output saved as an Excel files (or even flat file) and then have the newly created file sent to people via email?
sorry im a complete newbie to SSIS.
In broad strokes, you'll have an SSIS package with 2 tasks and 3 connection manager.
The first task is a Data Flow Task. Much as the name implies, the data is going to flow here - in your case, from SQL Server to Excel.
In the Data Flow task, add an OLE DB Source to the data flow. It will ask what Connection Manager to use and you'll create a new one pointed at your source system. Change the source from the Table Selector to a Query and then reference your stored procedure EXECUTE dbo.ExportDaily'
Hopefully, the procedure is nothing more than select col1, col2, colN from table where colDate = cast(getdate() as date) Otherwise, you might run into challenges for the component to determine the source metadata. Metadata is the name of the game in an SSIS data flow. If you have trouble, the resolution is version dependent - pre 2012 you'd have a null operation select as your starting point. 2012+ you use the WITH RESULT_SETS to describe the output shape.
With our source settled, we need to land that data somewhere and you've indicated Excel. Drag an Excel destination onto the canvas and again, this is going to need a connection manager so let it create one after you define where the data should land. Where you land the data is important. On your machine, C:\user\pmaj\Documents is a valid path, but when this runs on a server as ServerUser1... Not so much. I have a pattern of C:\ssisdata\SubjectArea\Input & Output & Archive folders.
Click into the Columns tab, and there's nothing to do here as it auto-mapped source columns to the destination. Sort the target column names by clicking on the header. A good practice is to scroll through the listing and look for anything that is unmapped.
Run the package and confirm that we have a new file generated and it has data. Close Excel and run it again. It should have clobbered the file we made. If it errors (and you don't have your "finger" on the file by having it open in Excel, then you need to find the setting in the Excel destination that says overwrite existing file)
You've now solved the exporting data to Excel task. Now you want to share your newfound wisdom with someone else and you want to use email to do so.
There are two ways of sending email. The most common will be the Email task. You'll need to establish a connection to your SMTP server and I find this tends to be more difficult in the cloud based world - especially with authentication and this thing running as an unattended job.
At this point, I'm assuming you've got a valid SMTP connection manager established. The Send Email Task is straightfoward. Define who is receiving the email, the subject, body and then add your attachment.
An alternative to the Send Mail Task, is to use an Execute SQL Task. The DBAs likely already have sp_send_dbmail configured on your server as they want the server to alert them when bad things happen. Sending your files through that process is easier as someone else has already solved the hard problems of smtp connections, permissions, etc.
EXECUTE msdb.dbo.sp_send_dbmail
#profile_name = 'TheDbasToldMeWhatThisIs'
, #recipients ='pmaj#a.com;billinkc#b.com'
, #subject = 'Daily excel'
, #body = 'Read this and do something'
, #file_attachments = 'C:\ssisdata\daily\daily.xlsx';
Besides using existing and maintained mechanism for mailing the files, Execute SQL Task is easily parameterized with the ? place holder so if you need to change profile as the package is deployed through dev/uat/prod, you can create SSIS Variables and Parameters and map values into the procedure's parameters and configure those values post deployment.
I have managed to make my Access work as a frontend for MySQL.
I have managed to make it work through connection string but because some specifics in code i would like to save DSN configuration as user DSN.
I have ran into one specific problem. I need to use option=3 inside my connection string because without option=3 i get error: The Microsoft Jet database engine stopped the process because you and another user are attempting to change the same data at the same time.
If i include option=3 in my connection string everything works well. The thing is, in Mysql Connector/ODBC data source configuration i do not know which checkbox/option represents option=3
The doc about this is here : Connector/ODBC Connection Parameters
option=3 looks deprecated as specified in this answer :
Option=3; corresponded to FLAG_FIELD_LENGTH (1) +
FLAG_FOUND_ROWS (2)
It looks indeed deprecated as in the doc I can't find any reference to FLAG_FIELD_LENGTH
We can thus assume that the flag you really need is FLAG_FOUND_ROWS
According to the doc, the GUI option for this flag is
Return matched rows instead of affected rows
I want to go through this tutorial. Unfortunately the author has already set up the datasources
and does not explain how to set them up. First off I installed an separate SSAS Instance in my sql server 2014. Then I tried to add a .mdf file via "Attach" but get the Error "AdventureWorks.detach_log could not be found in the folder". So according to this SO solution I tried this command:
CREATE DATABASE YAFnet ON (FILENAME = N'C:\sql_data\YAFnet.mdf')
FOR ATTACH_REBUILD_LOG;
within my SSAS instance query editor but it looks like the query is not a proper one since it is mdx.
Anyone who can help me to get a datasource (adventureworks dw) for my tabular model so I can follow the tutorial?
I would download the tabular backup from AW samples and recover the .abf file
I have created a new Schema in a database called Contexts. Now when I want to write a query, Management Studio doesn't recognize the tables that belong to the new Schema. It says: 'Invalid object name Contexts.ContextLibraries'...
Transact-SQL:
INSERT INTO [Contexts].[ContextLibraries] (ChannelId, [IsSystem])
VALUES (#ChannelId, 1)
When I try the same thing on my local database, it does work...
Any ideas?
I did try to change the Default schema for the user from dbo to Contexts but this doesn't work. Also checked Contexts in Schemas owned by this user without success.
Update: Apparently the sql query does work but the editor gives a fault saying the object is invalid.
Try to refresh local cache of Management Studio:
Management Studio Menu >> Edit >> IntelliSense >> Refresh Local Cache
or use shortcut:
CTRL + SHIFT + R
I always forget that it's there.
You may need to refresh SSMS: if raw SQL works.
Frankly, the easiest way is to close object explorer on the server and re-open. The SQL Server client tools have a problem with caching back into the Jurassic period...
I need to know if it is possible to dynamically bind a textbox residing within a datarepeater to a 'dynamically' created BindingSource. I am using VB.net. The database I am using is a MySQL database.
I have to use the connection dynamically due to the fact that the database my not permanently reside on the same server.
[edit]
ok, so it seams that I am a dolt when asking questions. The app that I am making is not web based. it is a simple (I hope) app that connects to a MySQL database, accesses a table so I can edit/view it. Current setup is using the Add DataSource wizard. I have successfully connected to the dbase dynamically using the mysql connector dll but without the textboxes set at design time to a datasource, I am unsure on how to 'link' them via the datarepeater.
Your connection string should be defined in your Web.Config, and if you move your database to a different server, it's just a matter of modifying the web.config entry. As long as you keep the connection string name the same, the BindingSource object will pick up the new value from the config.edit
In truth, the same concept should apply here as it does in the web app answer listed above.
All of your data objects should be hard-coded, and it's just the connection string (which you'll have to either ask the user for, or push out as update when the DB moves) which will get modified.
For example, create a App.Config file in your project. Have one of your configuration values be the connection string. This config value will be where you go to get the connection string whenever you need it. Then your wizard will be there to allow users to easily modify the connection.
then look in app.config
the conenction string should be there.
If it is not then you should put it in here as you can change this file at any time and not have to recompile your app.