从 Visual Foxpro 向 SQL Server 数据库发送串联查询

发布于 2024-12-28 15:36:38 字数 315 浏览 0 评论 0原文

我使用 Visual Foxpro 9 和 SQL Server 作为后端。我正在执行此查询以使用 unicode 文本更新现有列值:

UPDATE <table> SET fname = "N('" + hexchr + "')"

问题是 Foxpro 将字符串存储为:

N(0945;0987;)

而当通过 SQL Server Management Studio 运行相同的命令时,该字符串存储为实际的 Devnagari 字体。

如何让 Foxpro 执行上面带有 N 的查询?

I am using Visual Foxpro 9 with SQL Server as back-end. I am executing this query to update an existing column value with a unicode text:

UPDATE <table> SET fname = "N('" + hexchr + "')"

The problem is Foxpro is storing string as:

N(0945;0987;)

whereas when the same command is run via SQL Server management studio, the string is stored as actual devnagari font.

How to make Foxpro execute the above query with the N?

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

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

发布评论

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

评论(1

阿楠 2025-01-04 15:36:38

我从未尝试过使用 Unicode 并提供 SQL-Server...但是,关于帮助防止 SQL 注入,在 VFP 中,当使用 SQL-Passthrough(SQLConnect()、SQLExec() 等)时,如果您写您的查询带有“?”占位符,它将从 VFP 内部查看变量...例如

myField = 0x123  && or whatever hex value... VFP leading with 0x implies hex
myKey = "whatever"

cSQLCmd = "update SomeTable set Field1 = ?myField where SomeKey = ?myKey"
nSQLHandle = sqlconnect( YourConnectionStringInfo )
SQLExec( nSQLHandle, cSQLCmd )
sqldisconnect( nSQLHandle )

VFP 将处理 ?通过各自找到的可用变量名称为您提供参数。话虽如此,VFP 仅基于 32 位,并且不相信它可以识别“unicode”值。您可能需要做的是在 SQL 中创建一个接受两个十六进制值(或其他值)的存储过程,然后调用它并根据需要将其传入。

I've never tried working with Unicode and feeding SQL-Server... However, with respect to helping prevent SQL-Injection, in VFP, when using SQL-Passthrough (SQLConnect(), SQLExec(), etc), If you write your query with "?" place-holder, it will look at the VARIABLE from within VFP... such as

myField = 0x123  && or whatever hex value... VFP leading with 0x implies hex
myKey = "whatever"

cSQLCmd = "update SomeTable set Field1 = ?myField where SomeKey = ?myKey"
nSQLHandle = sqlconnect( YourConnectionStringInfo )
SQLExec( nSQLHandle, cSQLCmd )
sqldisconnect( nSQLHandle )

VFP will handle the ? parameters for you by their respective found variable names that are available. Now, all that being said, VFP was only based on 32 bit, and don't believe it recognizes "unicode" values. What you may need to do is create a stored procedure in SQL that accepts two hex value (or whatever), and call that and pass it in as so required.

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