使用 Visual FoxPro 将数据库转储导入到 mysql

发布于 2024-11-24 18:13:02 字数 281 浏览 0 评论 0原文

我使用 leaves stru2mysql.prg 和 vfp2mysql_upload.prg 从 DBF 创建一个 .sql 转储文件。我使用 ODBC 从 vfp 连接到 mysql 数据库。我知道如何上传 sql 转储文件,但我需要自动化整个过程,即创建转储文件后,我的 Visual FoxPro 程序可以在没有第三方的情况下上传转储文件(自动)。我想过使用 source 命令,但需要在 mysql 提示符下运行。这里的假设是我的最终用户不知道如何导入(其中大多数人不知道)。请建议我如何自动将 sql 文件导入到mysql数据库。谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ぇ气 2024-12-01 18:13:02

我认为您正在寻找的是 Foxpro 中的各种 SQL* 函数。请参阅有关 SQLCONNECT(或 SQLSTRINGCONNECT)、SQLEXECSQLDISCONNECT 函数的 VFP 帮助或 MSDN 以开始使用。 Microsoft 在文档中为每个内容提供了很好的示例。

您可能还想使用FILETOSTR 将Leafe 程序的输出获取到SQLEXEC 函数的字符串中。

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.

如果没有 2024-12-01 18:13:02

以下是我从 Visual FoxPro 数据库获取数据并上传到 MySql 数据库的步骤。这些都被放入表单上的自定义方法中,该方法由命令按钮触发。例如,方法为“uploadnewdata”,我为所需的数据表传递参数

1) 连接到服务器 - 我使用 MySql ODBC
2)验证用户(这使用 SQLEXEC 为用户表提取正确的匹配记录
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) 一旦成功,我将创建我的基本游标(这是我发送的游标)
4)然后我循环遍历该游标,为字段中的值创建变量
5)然后使用SQLEXEC和INSERT INTO,我更新每条记录
6) 一旦程序完成对光标的处理,它会生成一个带有“完成”消息的消息框,并且控制返回到表单。

用户所要做的就是选择起始表并输入他们的登录信息

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文